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
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.
<[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:
>
>> 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
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 (
> 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
"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
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
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