Defining a new kind of sequence
A common requirement that we have when performing statistical analysis is to compute basic means, modes, and standard deviations on a collection of data. Our blackjack simulation will produce outcomes that must be analyzed statistically to see if we have actually invented a better strategy.
When we simulate a playing strategy, we should wind up with some outcome data that will be a sequence of numbers that show us the final result of playing a sequence of hands with a given strategy. The rate of play varies from about 50 hands per hour at a crowded table to 200 hands per hour if one is alone with the dealer. We'll assume 200 hands as two hours of blackjack before having to take a biology break.
We could accumulate the outcomes into a built-in list
class. We can compute the mean via , where N is the number of elements in x:
def mean( outcomes ): return sum(outcomes)/len(outcomes)
Standard deviation can be computed via :
def stdev( outcomes ): n= len(outcomes...