Take the 2-minute tour ×

This question already has an answer here:

I have a dictionary in my program and each of the value is a list of response times. I need to calculate the 95 percentile response time for each of these lists. I know how to calculate the average, But have no idea about 95 percentile calculation. Any pointers would be appreciated.

The following is the dictionary output of my program

finalvalues = {'https://lp1.soma.sf.com/img/chasupersprite.qng?v=182-4': ['505', '1405', '12', '12', '3'], 'https://lp1.soma.sf.com/img/metaBar_sprite.dsc': ['154', '400', '1124', '82', '94', '108']}

share|improve this question

marked as duplicate by Ashwini Chaudhary, root, Haidro, Stony, tkanzakic Jun 12 '13 at 7:39


Check this out : code.activestate.com/recipes/… –  Ashwini Chaudhary Jun 12 '13 at 4:53

2 Answers 2

up vote 2 down vote accepted
import numpy as np
for i in finalvalues.values():
    print np.percentile(map(int,i),95)
share|improve this answer
That is what I was looking for. I wanted the 95 percentile of the values inside a dictionary. Thanks Richie! –  Surianan Jun 12 '13 at 17:51

Use scipy.stats.norm.interval(confidence, loc=mean, scale=sigma) where confidence is a value between 0 and 1, in your case, it would be .95. mean would be the mean of your data and sigma would be your sample standard deviation. The output of this will be a tuple, where the first value is the lower bound and the second value is the upper bound on the interval. Hope this helps.

share|improve this answer
This is only applicable to a normal distribution. –  Gabriel Oct 13 at 15:54
