Reputation: 1566
How do I calculate the inverse of the log normal cumulative distribution function in python? I'm trying to translate some functions from Excel that uses the function [LOGINV][1]
For example
LOGINV(0,005;2;0,5) yields 2,0382373
where 0,005
is the probability, 2
is the mean and 0,5
is the std.
Does scipy.stats
have a similar function that I may apply?
Upvotes: 5
Views: 7192
Reputation: 17680
Yes:
from scipy import stats
import numpy as np
stats.lognorm(0.5, scale=np.exp(2)).ppf(0.005)
from http://docs.scipy.org/doc/scipy-0.17.0/reference/generated/scipy.stats.lognorm.html
Please check the meaning of your quantities. Actually 2 and 0.5 are the mean and the std-deviation of the random variable Y=exp(X), where X is the log-normal defined in the code (as also written in the excel documentation). The mean and the std-deviation of the distribution defined in the code are 8.37 and 4.46
Upvotes: 9