T
Ted Nienstedt
Gentlemen, et al:
The stddev function in the current, as of 11/03, utils.py module has a
bug. Corrected code excerpt below, in red; comments in blue.
Ted Nienstedt
(e-mail address removed)
def mean(values):
"""Return the arithmetic average of the values."""
return sum(values) / float(len(values))
def stddev(values, meanval=None):
"""The standard deviation of a set of values.
Pass in the mean if you already know it."""
if meanval == None: meanval = mean(values)
#return math.sqrt( sum([(x - meanval)**2 for x in values]))
# the above was missing the crucial divide by n-1 !
return math.sqrt( sum([(x - meanval)**2 for x in values]) /
(len(values)-1) )
The stddev function in the current, as of 11/03, utils.py module has a
bug. Corrected code excerpt below, in red; comments in blue.
Ted Nienstedt
(e-mail address removed)
def mean(values):
"""Return the arithmetic average of the values."""
return sum(values) / float(len(values))
def stddev(values, meanval=None):
"""The standard deviation of a set of values.
Pass in the mean if you already know it."""
if meanval == None: meanval = mean(values)
#return math.sqrt( sum([(x - meanval)**2 for x in values]))
# the above was missing the crucial divide by n-1 !
return math.sqrt( sum([(x - meanval)**2 for x in values]) /
(len(values)-1) )