How can I find probability between certain values from the lognormal distribution probability density function with Python? Thank you.
Asked
Active
Viewed 273 times
1 Answers
-1
I would suggest using Scipy to calculate these kind of probability functions. Example of what you asked:
import scipy.stats as stats
print(stats.lognorm(1.).cdf(.7)-stats.lognorm(1.).cdf(.5))
Here is the link with documentation about a.o. the parameters. http://pageperso.lif.univ-mrs.fr/~francois.denis/IAAM1/scipy-html-1.0.0/generated/scipy.stats.lognorm.html

DwightFromTheOffice
- 500
- 4
- 15
-
Thank you so much and can I ask something too, this code is works and for example I wonder of probabiliy on the probability denstiy function between 150-200 values, so this code is how should be? I'm new on this subject, I'm sorry if I asked the wrong thing please – tuba May 10 '21 at 15:02
-
You would have to calculate stats.lognorm(1.).cdf(200)-stats.lognorm(1.).cdf(150). But this is for the lognormal distribution with sigma=1 and mu=0, if you want the result for a lognormal distribution with other parameters, you will have to change the (1.) and do some translation. – DwightFromTheOffice May 11 '21 at 06:44