[Numpy-discussion] Newbie Installation problems

Chris Barker chrishbarker at home.net
Tue Aug 28 13:40:10 EDT 2001


Charles G Waldman wrote:

> I think there are some statistics modules floating around on the Net,
> but mean and standard deviation are one-liners in NumPy:
> 
> from Numeric import *
> 
> def mean(a):
>     return float(sum(a))/len(a)
> 
> def std_dev(a):
>     return sqrt(mean((a-mean(a))**2))

or, for the unbiased estimate:

def std_dev(a):
    return sqrt(sum((a-mean(a))**2)/(len(a)-1))

You can also find these in Mlab.py

-Chris

-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------




More information about the NumPy-Discussion mailing list