Popular recipes tagged "statistics"http://code.activestate.com/recipes/tags/statistics/2012-10-06T15:33:40-07:00ActiveState Code RecipesDisk usage (Python)
2012-10-06T15:33:40-07:00Giampaolo RodolĂ http://code.activestate.com/recipes/users/4178764/http://code.activestate.com/recipes/577972-disk-usage/
<p style="color: grey">
Python
recipe 577972
by <a href="/recipes/users/4178764/">Giampaolo RodolĂ </a>
(<a href="/recipes/tags/disk/">disk</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/space/">space</a>, <a href="/recipes/tags/statistics/">statistics</a>, <a href="/recipes/tags/usage/">usage</a>).
Revision 6.
</p>
<p>Provides disk usage statistics (total, used and free disk space) about a given path.</p>
<p>This recipe was initially developed for psutil:</p>
<ul>
<li><a href="http://code.google.com/p/psutil/issues/detail?id=172" rel="nofollow">http://code.google.com/p/psutil/issues/detail?id=172</a></li>
</ul>
<p>...and then included into shutil module starting from Python 3.3:</p>
<ul>
<li><a href="http://mail.python.org/pipermail/python-ideas/2011-June/010480.html" rel="nofollow">http://mail.python.org/pipermail/python-ideas/2011-June/010480.html</a></li>
<li><a href="http://bugs.python.org/issue12442" rel="nofollow">http://bugs.python.org/issue12442</a></li>
<li><a href="http://docs.python.org/dev/library/shutil.html#shutil.disk_usage" rel="nofollow">http://docs.python.org/dev/library/shutil.html#shutil.disk_usage</a></li>
</ul>
<p>The recipe you see here is a modified version of the latter one in that the Windows implementation uses ctypes instead of a C extension module. As such it can be used with python >= 2.5.</p>
Dirt simple map/reduce (Python)
2011-05-15T16:46:55-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577676-dirt-simple-mapreduce/
<p style="color: grey">
Python
recipe 577676
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/analysis/">analysis</a>, <a href="/recipes/tags/crosstab/">crosstab</a>, <a href="/recipes/tags/functional/">functional</a>, <a href="/recipes/tags/map_reduce/">map_reduce</a>, <a href="/recipes/tags/pivot_table/">pivot_table</a>, <a href="/recipes/tags/statistics/">statistics</a>).
Revision 9.
</p>
<p>Simple tool for analyzing datasets.</p>
Python reader for spss sav files (Python)
2011-07-25T18:59:49-07:00Albert-Jan Roskamhttp://code.activestate.com/recipes/users/4177640/http://code.activestate.com/recipes/577650-python-reader-for-spss-sav-files/
<p style="color: grey">
Python
recipe 577650
by <a href="/recipes/users/4177640/">Albert-Jan Roskam</a>
(<a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/pasw/">pasw</a>, <a href="/recipes/tags/sav/">sav</a>, <a href="/recipes/tags/spss/">spss</a>, <a href="/recipes/tags/statistics/">statistics</a>).
Revision 3.
</p>
<p><strong>Python Program to read Spss system files (.sav)</strong></p>
<ul>
<li><em>* version 2 (FASTER!) *</em></li>
<li>Requires spssio32.dll, which can be freely downloaded from:
<a href="https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/We70df3195ec8_4f95_9773_42e448fa9029/page/Downloads%2520for%2520IBM%25C2%25AE%2520SPSS%25C2%25AE%2520Statistics?lang=en" rel="nofollow">https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/We70df3195ec8_4f95_9773_42e448fa9029/page/Downloads%20for%20IBM%C2%AE%20SPSS%C2%AE%20Statistics?lang=en</a></li>
<li>You can also find this dll in the installation directory of SPSS (although SPSS is _not_ needed!)</li>
<li><p>The .dll should be saved in the same location as this program.</p></li>
<li><p>Parameters:
<em>savFileName</em>: the file name of the spss data file;
<em>returnHeader</em>: Boolean that indicates whether the first record
should be a list of variable names (default: True);
<em>recodeSysmisTo</em>: indicates to which value missing values should
be recoded (default: "");
<em>selectVars</em>: indicates which variables in the file should be
selected.The variables should be specified as a list or a tuple
of valid variable names. If None is specified, all variables
in the file are used (default: None);
<em>verbose</em>: Boolean that indicates whether information about the
spss data file (e.g., number of cases, variable names, file
size) should be printed on the screen (default:
True). <br />
<em>rawMode</em>: Boolean that indicates whether values should get
SPSS-style formatting,and whether date variables (if present)
should be converted to ISO-dates. If True, the program does not
format any values, which increases processing speed. (default:
= False)
<em>interfaceEncoding</em> Indicates the mode in which text communicated
to or from the I/O Module will be. Valid values are 'UTF-8' or
'CODEPAGE' (default = 'CODEPAGE')</p></li>
<li><p>Typical use:
savFileName = "d:/someFile.sav"
with SavReader(savFileName) as sav:
header = sav.next()
for line in sav:
process(line)</p></li>
<li><p>Note:
--<em>New version</em>: If you downloaded this previously, use the current version as it is <strong>MUCH faster!!</strong>
--this code currently only works on Windows (32 bits). I might make it work on Linux Ubuntu 10 at some point.
--date fields in spss are represented as the number of seconds since the Gregorian calendar. The program converts these, wherever possible, to ISO-dates (yyyy-mm-dd).</p></li>
</ul>
<p>Any feedback is welcome! I'm still learning!</p>
ActiveState recipe statistics (Python)
2011-06-02T14:52:50-07:00Kaan Ozturkhttp://code.activestate.com/recipes/users/4178179/http://code.activestate.com/recipes/577732-activestate-recipe-statistics/
<p style="color: grey">
Python
recipe 577732
by <a href="/recipes/users/4178179/">Kaan Ozturk</a>
(<a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/regular_expressions/">regular_expressions</a>, <a href="/recipes/tags/statistics/">statistics</a>, <a href="/recipes/tags/urllib2/">urllib2</a>, <a href="/recipes/tags/web/">web</a>).
Revision 2.
</p>
<p>Downloads "All Recipe Authors" pages in ActiveState, uses regular expressions to parse author name and number of their recipes on each page. Finally, it displays the recipe submission distribution (the count of how many authors have submitted how many recipes each).</p>
monty hall problem (Python)
2010-08-25T20:02:17-07:00markcannolihttp://code.activestate.com/recipes/users/4174766/http://code.activestate.com/recipes/577374-monty-hall-problem/
<p style="color: grey">
Python
recipe 577374
by <a href="/recipes/users/4174766/">markcannoli</a>
(<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/statistics/">statistics</a>).
</p>
<p>Monty_Hall is a gameshow host that proves that it is statistically better to switch when offered the chance after getting additional knowledge in a fair game. The caveat is "statistically better", which means any single trial can have unsupporting results. But "statistically better" is exactly where the fist-fights at bars and family reunions start, so no matter the single trial outcomes.</p>
Fast Running Median using an Indexable Skiplist (Fast version) (Python)
2010-03-03T11:06:29-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577073-fast-running-median-using-an-indexable-skiplist-fa/
<p style="color: grey">
Python
recipe 577073
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/indexable/">indexable</a>, <a href="/recipes/tags/median/">median</a>, <a href="/recipes/tags/running/">running</a>, <a href="/recipes/tags/skiplist/">skiplist</a>, <a href="/recipes/tags/statistics/">statistics</a>).
Revision 5.
</p>
<p>Fast version of r576930 reimplemented using a list of lists instead of a node class. </p>