mean ans std dev of an array?

Paul Rubin http
Mon Oct 23 18:04:13 EDT 2006


"SpreadTooThin" <bjobrien62 at gmail.com> writes:
> print a.mean()
> print a.std_dev()
> 
> Is there a way to calculate the mean and standard deviation on array data?

Well, you could use numpy or whatever.  If you want to calculate directly,
you could do something like (untested):

n = len(a)
mean = sum(a) / n
sd = sqrt(sum((x-mean)**2 for x in a) / n)



More information about the Python-list mailing list