[SciPy-user] scoreatpercentile on 2D array gives unexpected result
Vincent
vincent.nijs@gmail....
Mon Sep 10 22:00:28 CDT 2007
I want to get certain percentiles of each column of an array (i.e.,
2.5th, 50th, and 97.5th).
Testing the scipy scoreatpercentile function i get some results I
didn't expect.
In [5]: z
Out[5]:
array([[1, 1, 1],
[1, 1, 1],
[4, 4, 3],
[1, 1, 1],
[1, 1, 1]])
The following works as expected:
In [6]: N.median(z)
Out[6]: array([1, 1, 1])
Now using scoreatpercentile:
In [54]: scipy.stats.scoreatpercentile(z,50)
Out[54]: array([3, 4, 4])
The function seems to assume the 2D array is already sorted and then
it sorts the returned array from low to high?
When I pass scoreatpercentile an array with one column things do seem
to work as I expect:
In [56]: scipy.stats.scoreatpercentile(z[:,0],50)
Out[56]: 1
Any ideas what is going on? Should I be using a different function?
Thanks,
Vincent
More information about the SciPy-user
mailing list