Closed GoogleCodeExporter closed 8 years ago
The way this works may be slightly counterintuitive, as the usual definition of
the
median (the value at the midpoint that you mention) is not the same as the
precise
statistical definition.
In the stats package the medianscore() function will produce the output that
you are
after:
>>> print stats.medianscore( xs )
0.18232101202
Now the median() function takes another parameter, numbins that, if set to
sufficiently high will approximate the medianscore() above:
>>> print stats.median( xs, numbins=100000 )
0.175937510922
As per the docstring:
"""
Returns the computed median value of a list of numbers, given the
number of bins to use for the histogram (more bins brings the computed value
closer to the median score, default number of bins = 1000). See G.W.
Heiman's Basic Stats (1st Edition), or CRC Probability & Statistics.
Usage: lmedian (inlist, numbins=1000)
"""
Original comment by istvan.a...@gmail.com
on 28 Jan 2008 at 1:55
Original issue reported on code.google.com by
yaa...@gmail.com
on 28 Jan 2008 at 7:09