Re: mean ans std dev of an array?

2006-10-25 Thread Frederic Rentsch
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? > > I quickly fish this out of my functions tool

Re: mean ans std dev of an array?

2006-10-24 Thread Robert Kern
Paul McGuire wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >>>> n = len(a) >>>> mean = sum(a) / n >>>> sd = sqrt(sum((x-mean)**2 for x in a) / n) >>... >>>> If there is a faster way... like transferring the array to a >>>> different container class.

Re: mean ans std dev of an array?

2006-10-24 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>> n = len(a) >>> mean = sum(a) / n >>> sd = sqrt(sum((x-mean)**2 for x in a) / n) >... >>> If there is a faster way... like transferring the array to a >>> different container class... but what? > > Perhaps: >

Re: mean ans std dev of an array?

2006-10-24 Thread skip
>> n = len(a) >> mean = sum(a) / n >> sd = sqrt(sum((x-mean)**2 for x in a) / n) ... >> If there is a faster way... like transferring the array to a >> different container class... but what? Perhaps: >>> import scipy >>> print scipy.mean([1,2,3,4,5,6]) 3.5

Re: mean ans std dev of an array?

2006-10-24 Thread SpreadTooThin
Paul Rubin wrote: > "SpreadTooThin" <[EMAIL PROTECTED]> 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 (

Re: mean ans std dev of an array?

2006-10-23 Thread Tim Chase
> 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? No, you don't have to...though there are likely some stats modules flo

Re: mean ans std dev of an array?

2006-10-23 Thread Paul Rubin
"SpreadTooThin" <[EMAIL PROTECTED]> 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

Re: mean ans std dev of an array?

2006-10-23 Thread Éric Daigneault lists
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 calculati

mean ans std dev of an array?

2006-10-23 Thread SpreadTooThin
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? -- http://mail.python.org/mailman/listinfo/python-list