[SciPy-user] scipy.stats.percentileofscore : something strange
Gary Strangman
strang at nmr.mgh.harvard.edu
Thu Dec 13 09:56:35 EST 2007
Yes, this is a bug. I believe there is no checking for edge or out of
bound cases. (At least there wasn't when it was first added to scipy ...)
Gary
On Thu, 13 Dec 2007, Samuel GARCIA wrote:
>
>
> Matthieu Brucher a écrit :
>>
>>
>> 2007/12/13, Samuel GARCIA <sgarcia at olfac.univ-lyon1.fr
>> <mailto:sgarcia at olfac.univ-lyon1.fr>>:
>>
>> Hi all,
>> I found something strange in scipy.stats.percentileofscore
>>
>> In [1]: from scipy import *
>>
>> In [2]: a = rand(10000)
>>
>> In [3]: stats.percentileofscore(a,.2)
>> Out[3]: 20.0157565073
>> This OK.
>>
>>
>> In [4]: stats.percentileofscore(a,.0002)
>> Out[4]: 102.898311442
>> This is strange !!!!!
>>
>>
>> This may be a bug
>>
>> In [5]: stats.percentileofscore(a,1.4)
>> ---------------------------------------------------------------------------
>> <type 'exceptions.IndexError
>> '> Traceback (most recent call last)
>>
>> //home/sgarcia//<ipython console> in <module>()
>>
>> /usr/lib/python2.5/site-packages/scipy/stats/stats.py in
>> percentileofscore(a, score, histbins, defaultlimits)
>> 942 cumhist = np.cumsum(h*1, axis=0)
>> 943 i = int((score - lrl)/float(binsize))
>>
>> --> 944 pct =
>> (cumhist[i-1]+((score-(lrl+binsize*i))/float(binsize))*h[i])/float(len(a))
>> * 100
>> 945 return pct
>> 946
>>
>> <type 'exceptions.IndexError'>: index out of bounds
>>
>> This does not work...
>>
>>
>> I expect this to raise this exception, you cannot take a percentile outside
>> [0, 1] (1.4 = 140%)
>
> I think that it should return 100 if superior to rigtht limit and 0 if
> inferior to left limit.
> No ?
>
>
>>
>> Matthieu
>> --
>> French PhD student
>> Website : http://matthieu-brucher.developpez.com/
>> Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
>> LinkedIn : http://www.linkedin.com/in/matthieubrucher
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user at scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-user
>>
>
>
More information about the SciPy-User
mailing list