0

I'm fitting a lognormal function to lognormal distributed data with the following code using scipy.stats.lognormal:

from scipy.stats import lognorm 
params = lognorm.fit(data, loc=0)

I get back three parameters. Now I want to calculate the mean and standard deviation of the underlying normal distribution. I know that I've to use the parameters I get back from scipy but I'm not sure how to make the calculation on these. This question is almost what I'm looking for but they calculate the mean and stddev of the lognormal and not the underlying normal distribution.

Edit:

I found this post where is done what I need, except that there is no scipy loc parameter included. In my case I want to keep this parameter during my conversation into mean and stddev.

riyansh.legend
  • 117
  • 1
  • 13
  • FYI: You used `loc=0`, but I suspect you meant to use `floc=0` to fix the location parameter to be 0. – Warren Weckesser May 22 '20 at 05:33
  • I did use `loc` as `floc` is not mentioned on the scipy site I linked. And indeed when I use `floc=0` I get different results for my fit, but they are not as good as when using `loc=0`. – riyansh.legend May 22 '20 at 05:45
  • 1
    They are not as good because they use only two parameters instead of three. Typically, the log-normal distribution does not include the "location" parameter (called `loc` in SciPy). If the three parameter version is the correct model for your data, then use it, but be aware that when most folks talk about the log-normal distribution, they are referring to the two parameter distribution. – Warren Weckesser May 22 '20 at 06:01
  • I did some research to find literature about this 3-parameter model used in `scipy` but wasn't able to find something. Is this approach documented somewhere outside of `scipy`? – riyansh.legend May 22 '20 at 06:30
  • *All* the continuous univariate distributions in SciPy are parametrized as [location-scale families](https://en.wikipedia.org/wiki/Location%E2%80%93scale_family): they have the location parameter `loc`, the scale parameter `scale`, and zero or more shape parameters. Changing the location parameter gives a translation of the distribution. Note that for the log-normal distribution, the mean of the underlying normal distribution is not a location parameter. – Warren Weckesser May 22 '20 at 15:37
  • I'm not sure if I got this correct. With your last sentence do you want to say that when I'm converting the `shape` and `scale` parameter of the lognormal distribution into mu and sigma of this lognormal distribution this is independent from the `loc` parameter so it can be ignored? – riyansh.legend May 22 '20 at 19:50
  • I answered a very similar question here: https://stackoverflow.com/a/74575196/659612 – ronomal Nov 25 '22 at 15:54

0 Answers0