# scipy.stats.percentileofscore : something strange

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 !!!!!

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 work...

Any idea.

Sam

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Samuel Garcia
Laboratoire de Neurosciences Sensorielles, Comportement, Cognition.
CNRS - UMR5020 - Universite Claude Bernard LYON 1
Equipe logistique et technique
50, avenue Tony Garnier
69366 LYON Cedex 07
FRANCE
T�l : 04 37 28 74 64
Fax : 04 37 28 76 01
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This list is for matplotlib, please try asking at the scipy mailing list.

···

On Thursday 06 December 2007 10:20:30 am Samuel GARCIA wrote:

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 !!!!!

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 work...

Any idea.

Sam

--
Darren S. Dale, Ph.D.
Staff Scientist
Cornell High Energy Synchrotron Source
Cornell University
275 Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

darren.dale@...163...
office: (607) 255-3819
fax: (607) 255-9001
http://www.chess.cornell.edu