[Numpy-discussion] non-standard standard deviation

Dr. Phillip M. Feldman pfeldman@verizon....
Sun Nov 29 16:13:11 CST 2009


All of the statistical packages that I am currently using and have used in
the past (Matlab, Minitab, R, S-plus) calculate standard deviation using the
sqrt(1/(n-1)) normalization, which gives a result that is unbiased when
sampling from a normally-distributed population.  NumPy uses the sqrt(1/n)
normalization.  I'm currently using the following code to calculate standard
deviations, but would much prefer if this could be fixed in NumPy itself:

def mystd(x=numpy.array([]), axis=None):
   """This function calculates the standard deviation of the input using the
   definition of standard deviation that gives an unbiased result for
samples
   from a normally-distributed population."""

   xd= x - x.mean(axis=axis)
   return sqrt( (xd*xd).sum(axis=axis) / (numpy.size(x,axis=axis)-1.0) )
-- 
View this message in context: http://old.nabble.com/non-standard-standard-deviation-tp26566843p26566843.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.



More information about the NumPy-Discussion mailing list