Calculate 95 percentile of list values ​​in python

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

The following is the output of my program dictionary

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 ']}

+7
source share
2 answers
import numpy as np for i in finalvalues.values(): print np.percentile(map(int,i),95) 
+10
source

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

+1
source

All Articles