I'm attempting to calculate the percentile rank of a score using the python statlib module. The percentileofscore function is supposed to return a value between 0 and 100, however it regularly produces numbers outside this range. An example:
>> a = [0,1,2,3,4,5]
>> percentileofscore(a, 0)
108.33333333333333
I've tried the scipy module, and have also rolled my own with similar results.
Am I misunderstanding something re. this function?
EDIT - More examples:
percentileofscore([23,23,23,25], 23)
137.5
percentileofscore([12,19,65,25], 12)
112.5
percentileofscore([112,109,605,25], 25)
112.5
Seems that querying the percentile of the lowest score causes the problem. A bug perhaps?
To calculate the rank percentile of a list data, you can use a formula. Select a blank cell that you will place the rank percentile at, type this formula =RANK. EQ(B2,$B$2:$B$9,1)/COUNT($B$2:$B$9), press Enter key and drag fill handle down to calculate all rank percentiles.
The percentile rank of a score is the percentage of scores in its frequency distribution that are equal to or lower than it. For example, a test score that is greater than 75% of the scores of people taking the test is said to be at the 75th percentile, where 75 is the percentile rank.
Percentiles are commonly used to report scores in tests, like the SAT, GRE and LSAT. for example, the 70th percentile on the 2013 GRE was 156. That means if you scored 156 on the exam, your score was better than 70 percent of test takers. The 25th percentile is also called the first quartile.
Divide your class rank by the number of students in your grade, multiply by 100, then subtract that number from 100. For example, if there are 600 students in your grade and you are ranked 120th, then you are in the 80th percentile because (120/600)*100=20, and 100-20=80. You are also in the top 20% of your class.
scipy.stats.percentileofscore seems to work as expected:
In [2]: import scipy.stats as stats
In [3]: stats.percentileofscore([0,1,2,3,4,5], 0)
Out[3]: 16.666666666666664
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With