def lmedian (inlist,numbins=1000):
    """
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)
"""
    (hist, smallest, binsize, extras) = histogram(inlist,numbins) # make histog
    cumhist = cumsum(hist)              # make cumulative histogram
    for i in range(len(cumhist)):        # get 1st(!) index holding 50%ile score
        if cumhist[i]>=len(inlist)/2.0:
            cfbin = i
            break
    LRL = smallest + binsize*cfbin        # get lower read limit of that bin
    cfbelow = cumhist[cfbin-1]
    freq = float(hist[cfbin])                # frequency IN the 50%ile bin
    median = LRL + ((len(inlist)/2.0 - cfbelow)/float(freq))*binsize  # median formula
    return median
def lmedian ( inlist , numbins = 1000 ) : ( hist , smallest , binsize , extras ) = histogram ( inlist , numbins ) cumhist = cumsum ( hist ) for i in range ( len ( cumhist ) ) : if cumhist [ i ] >= len ( inlist ) / 2.0 : cfbin = i break LRL = smallest + binsize * cfbin cfbelow = cumhist [ cfbin - 1 ] freq = float ( hist [ cfbin ] ) median = LRL + ( ( len ( inlist ) / 2.0 - cfbelow ) / float ( freq ) ) * binsize return median
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)