The following (uncommitted) test currently fails. The reason is that mlab.prctile(x,50) doesn't handle even length sequences according to the numpy and wikipedia convention for the definition of median. Do we agree that it should pass?

Not only would I commit the test, but I also have a fix to make it pass, derived from scipy.stats.scoreatpercentile().

This would affect boxplot, if not more.

def test_prctile():

# test odd lengths

x=[1,2,3]

assert mlab.prctile(x,50)==np.median(x)

# test even lengths

x=[1,2,3,4]

assert mlab.prctile(x,50)==np.median(x)

# derived from email sent by jason-sage to MPL-user on 20090914

ob1=[1,1,2,2,1,2,4,3,2,2,2,3,4,5,6,7,8,9,7,6,4,5,5]

p = [75]

expected = [5.5]

# test vectorized

actual = mlab.prctile(ob1,p)

assert np.allclose( expected, actual )

# test scalar

for pi, expectedi in zip(p,expected):

actuali = mlab.prctile(ob1,pi)

assert np.allclose( expectedi, actuali )