Finding the area under the curve of a probability distribution function in SciPy

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

Answers (2)

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

pyano
pyano

Reputation: 1978

Something like this (?):

a = np.array([1, 2, 3, 4, 6, 7, 8, 9])

np.percentile(a, 50)

5.0

Upvotes: 1

Related Questions