Reputation: 747
To the find the probability a number is greater than x using scipy.stats.norm
you could write a function like this 1-scipy.stats.norm(55.98,12.29).cdf(64)
returning 0.257 meaning that given a mean of 55.98 and a standard deviation of 12.29, there is a 25.7% probability your random observation will be greater than 64? If I wanted to find the logarithmic normal distribution could I do the same with the scipy.stats.lognorm
function? 1-scipy.stats.lognorm(55.98,12.29).cdf(64)
?
Upvotes: 0
Views: 438
Reputation: 1375
You have the correct interpretation for the normal distribution.
For lognorm, the scipy parameterization is a little weird.
Suppose X is a normally distributed random variable with mean mu and std dev sigma. If Y is defined such that X = ln(Y), then Y has a log normal distribution.
To represent Y in scipy, you do this:
from scipy.stats import lognorm
from math import exp
#using smaller numbers for this example
mu=1
sigma=2
X=norm(mu,sigma)
X.mean() #1.0
X.var() # 4.0
Y = lognorm(s=sigma,scale=exp(mu))
Y.mean() # 20.085536923187668
Y.var() #21623.037001313976
This produces the same result as the wikipedia lognorm formulas for:
In all cases in scipy, the .cdf(x) method gives you the probability that the random variable is less than or equal to x.
Upvotes: 1