Reputation: 89
I'm working on a univariate problem which involves aggregating payment data on a customer level - so that I have one row per customer, and the total amount they've spent with us.
Using this distribution of payment data, I fit an appropriate probability distribution and calculated the maximum likelihood estimates for the parameters of the pdf.
Now I want to find the 90th percentile of the distribution. If I was to do this by hand I would set .10 equal to the integral from x to infinity of my pdf and then solve for x.
Is there a package in python/scipy/statsmodels that allows me to do this?
Thanks in advance!
Cheers
Upvotes: 2
Views: 1181
Reputation: 89
Eureka! It's the .interval()
method for a rv_continuous object in scipy.stats
- just pass in your parameters and it will give you end points that contain that percentage of the distribution.
Upvotes: 1
Reputation: 1978
Something like this (?):
a = np.array([1, 2, 3, 4, 6, 7, 8, 9])
np.percentile(a, 50)
5.0
Upvotes: 1