I want to transform some data points, which I assume follow an unknown non-standard lognormal distribution, to follow a normal distribution.
When I fit the data with a lognormal distribution using scipy, I get a non-zero value for the loc parameter (shift).
So I use the following procedure:
- I fit a lognormal distribution to my data to find the value of the shift parameter (loc)
- I shift the data: data - loc
- I compute the natural logarithm of the data
In code the procedure is the following:
data = ... # pandas series
shape, loc, scale = lognorm.fit(data) # fit the data
data = data.apply(lambda x: np.log(x - loc)) # shift and apply logarithm
In some answers, such as this,they just say to take the logarithm of the data, and do not address a possible shift.
In my case this would be possible because the data is shifted to the right, so values are all positive, but would I obtain normally distributed data? I think that, depending from the shift, the transformed data would deviate from normality. Am I wrong?
To summarize these are my questions:
- is my procedure correct?
- If I don't shift the data, to save on the computational complexity of fitting the distribution (in my application this is important), do I introduce an error (deviation from normality)? If yes, can I quantify it in some way?
loc
argument in the scipy implementation which is not reflected in the formula there. As a rule you should not assume this is what someone means when referring to "lognormal" unless they have stated otherwise. $\endgroup$