Alexander Kleinhans
Alexander Kleinhans

Reputation: 6258

python: finding the value of a random variable for a cdf

I apologize in advance if this is poorly worded.

If I have a stdDev = 1, mean = 0, scipy.stats.cdf(-1, loc = 0, scale = 1) will give me the probability that a normally distributed random variable will be <= -1, and that is 0.15865525393145707.

Given 0.15865..., how do I find the value that gives me -1?

i.e. value(cdf = 0.15865, loc = 0, scale = 1)

Thanks for the help.

Upvotes: 2

Views: 1408

Answers (1)

Alexander Kleinhans
Alexander Kleinhans

Reputation: 6258

edit: you actually need import norm from scipy.stats.

I found the answer. You need to use ppf in scipy.stats which stands for "percent point function".

So let's say you have a normal distribution with stdDev = 1, and mean = 0 and you want to find the value at which the random variables will be below ~15% of the time. Just use:

value = norm.ppf(0.15, loc = 0, scale = 1)

This will return ~ -1, likewise if you do:

cdf = norm.cdf(-1, loc = 0, scale = 1)

This will return ~ 0.15 or 15%.

Cool beans.

Upvotes: 3

Related Questions