basic statistics in python
Tim Churches
tchur at optushome.com.au
Fri Mar 15 17:43:45 EST 2002
dsavitsk wrote:
>
> this is really embarassing :-)
>
> >>> import win32com.client
> >>> xl = win32com.client.Dispatch('Excel.Application')
> >>> xl.WorksheetFunction.StDev(1,1,1,3,3,45,3,2,1,1,2,3,2,1)
> 11.565627361442019
> >>> xl.WorksheetFunction.Pearson((1,4,3,2,5),(5,3,2,5,4))
> -0.48507125007266594
Hmm, how about these legacy-free solutions...
Using Walter Moreira's RPy module ( http://rpy.sourceforge.net ) and R (
http://www.r-project.org ):
>>> from rpy import *
>>> r.var((1,1,1,3,3,45,3,2,1,1,2,3,2,1)) ** 0.5
11.565627361442019
>>> r.cor((1,4,3,2,5),(5,3,2,5,4))
-0.48507125007266594
Or using Gary Strangman's stats.py module (
http://www.nmr.mgh.harvard.edu/Neural_Systems_Group/gary/python.html ):
>>> from stats import *
>>> stdev((1,1,1,3,3,45,3,2,1,1,2,3,2,1))
11.565627361442017
>>> pearsonr((1,4,3,2,5),(5,3,2,5,4))
(-0.48507125007266594, 0.40754435760237651)
Note that stats.py also returns the 2-tailed p-value as well (which can
also easily be obtained from R via RPy).
Tim C
More information about the Python-list
mailing list