mean ans std dev of an array?

Éric Daigneault lists daigno at gmail.com
Tue Oct 24 00:04:26 CEST 2006


Simplest I see is to do it manually.

If your array data is  numeric compatible

mean = sum(a)/len(a)

as for the standard Deviation it depends on the nature of your data...  
check out http://en.wikipedia.org/wiki/Standard_deviation  for info on 
that...  but in all a for loop with a few calculation within should be 
enough

I know no "standard" way to do this in python

Have not tested above code but it should work

Éric

SpreadTooThin wrote:
> import array
> a = array.array('f', [1,2,3])
>
> print a.mean()
> print a.std_dev()
>
> Is there a way to calculate the mean and standard deviation on array
> data?
>
> Do I need to import it into a Numeric Array to do this?
>
>   




More information about the Python-list mailing list