Issue
Is there any python/numpy function that calculates n-th percentile of given probability distribution?
# Like This
distr = [.2, .6, .2]
do_some_magic(distr, 50) # 1
distr = [.1, .1, .6, .2]
do_some_magic(distr, 50) # 2
Solution
Yes, you can use scipy's percentileofscore
.
from scipy.stats import percentileofscore
distr = [.2, .6, .2]
print(percentileofscore(distr,50)/100)
1.0
Answered By - Machetes0602 Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.