stochastic programsprobabilityand statistics of the population (and since we are usually dealing with infinite populationse all possible sequences of coin flipsthis is usually impossibleof coursethis is not to say that an estimate cannot be precisely correct we might flip coin twiceget one heads and one tailsand conclude that the true probability of each is we would have reached the right conclusionbut our reasoning would have been faulty how many samples do we need to look at before we can have justified confidence in our answerthis depends on the variance in the underlying distribution roughly speakingvariance is measure of how much spread there is in the possible different outcomes we can formalize this notion relatively simply by using the concept of standard deviation informallythe standard deviation tells us what fraction of the values are close to the mean if many values are relatively close to the meanthe standard deviation is relatively small if many values are relatively far from the meanthe standard deviation is relatively large if all values are the samethe standard deviation is zero more formallythe standard deviations (sigma)of collection of valuesis defined as |!!"#(!where |!is the size of the collection and (muits mean figure contains python implementation of standard deviation we apply the type conversion floatbecause if each of the elements of is an intthe type of the sum will be an int def stddev( )"""assumes that is list of numbers returns the standard deviation of ""mean float(sum( ))/len(xtot for in xtot +( mean)** return (tot/len( ))** #square root of mean difference figure standard deviation we can use the notion of standard deviation to think about the relationship between the number of samples we have looked at and how much confidence we should have in the answer we have computed figure contains modified version of flipplot it runs multiple trials of each number of coin flipsand plots the means for abs(heads tailsand the heads/tails ratio it also plots the standard deviation of each you'll probably never need to implement this yourself statistical libraries implement this and many other standard statistical functions howeverwe present the code here on the off chance that some readers prefer looking at code to looking at equations