954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Python - statistical functions + a list

1. Does Python have some built in statistical functions - eg. like PERCENTILE, Root Mean Square etc ?

I tried Python help and the web, to no avail. I checked standard Python maths functions and could not find anything too.

If there is nothing built in then is there a library out there to 'import' ?

2. How to list all Pythoon blocks / functions currently being installed on a system ? So that I can quickly see what is available for use

thanks

db_ozbecool
Newbie Poster
7 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

1/ if you type "statistics module python" in a google search engine, you'll find easily some modules with functions for statistics, so don't say you've searched the web !
2/ The list of all modules which come by default with the python distribution can be browsed in the documentation here http://docs.python.org/modindex.html . Other modules installed on your system should be in a folder called "site-packages" in your python library. Of course, you may have installed python modules elsewhere on your system. Run python like this

>>> import sys
>>> print sys.path
['', '/usr/lib/python2.5/site-packages/Pygments-0.8.1-py2.5.egg', '/home/eric/pymods', '/usr/lib/ooo-2.2/program', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/usr/lib/python2.5/site-packages/gtk-2.0', '/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode']

The result is a list of folders where python looks for modules when you 'import' something. So you could look in these folders if you see some other modules installed (the list will be different on your system of course) !

Gribouillis
Posting Maven
Moderator
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
 

Have you considered the scipy package? It contain loads of statistical function, which operate on numpy arrays. You can easily convert any numeric list into a numpy array.

sjvr767
Newbie Poster
7 posts since Oct 2007
Reputation Points: 10
Solved Threads: 1
 

Simply use this:

# list all the modules Python currently knows about ...
help("modules")
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
 

I tried this, with strange results. It looks like python tries to load modules...

Gribouillis
Posting Maven
Moderator
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
 

help("modules")
hangs up on bad or modified modules or mixed versions, but lets you know!
Works well on virgin installations.

I have so many modules installed and screw around with them all the time. So I use help("modules") to flush out the bad stuff.

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

thanks for modules lists. I still do not know how to get to statistics functions.

On http://docs.python.org/modindex.html I do no see anything for statistics

Web search with "statistics module python":
- http://starship.python.net/crew/hinsen/scientific.html - link is dead
- http://cvs.sourceforge.net/viewcvs.py/*checkout*/python/python/nondist/sandbox/statistics/statistics.py - link is dead

What I need is a ready to use module(s) from which I can call a function I need and that's it - just like with other modules.
May be I am not as good at web search as others, if you are and are willing to help then please send me a link etc.

db_ozbecool
Newbie Poster
7 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 
Gribouillis
Posting Maven
Moderator
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
 

RE: stats.py :
http://code.google.com/p/python-statlib/ and http://www.nmr.mgh.harvard.edu/Neural_Systems_Group/gary/python.html is buggy - eg. it does not calculate PERCENTILE even close to th ecorrect value

db_ozbecool
Newbie Poster
7 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

For future reference, it seems that matplotlib at sourceforge.net (matplotlib.sourceforge.net) would be one solution to statistical calcs like percentile and root mean square, in addition to checking the scipy programs.

woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You