# Fitting data to a Log-normal distribution

I tried to fit my data to a log-normal distribution, but I didn't get a correct result. Can anyone help to find out how to do this?

x = {500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600};
y = {3891.13897, 6447.2735, 6379.05724, 4781.9429, 3236.44741,
2283.12663, 1.81827, 1132.17598, 733.89458, 487.24879, 321.50395};

• I suggest posting the data in a more friendly form first. Preferably in a column format and using the code tags.
– Q.P.
Sep 11 '16 at 17:03
• I hope now its fine. Thank you for your suggestion. Sep 11 '16 at 17:13
• You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this meta Q&A helpful -- The idea is to make it so that others can copy-paste it into the software Mathematica. It makes it convenient for them and more likely you will get someone to help you. You will need to put the data in proper Mathematica syntax. Sep 11 '16 at 17:26
• The y-values aren't counts or relative frequencies so why would you want to fit a probability distribution? Do you want to fit a curve that happens to have the same shape as a lognormal probability density function?
– JimB
Sep 11 '16 at 17:35
• And is the value 1.81827 correct?
– JimB
Sep 11 '16 at 17:37

I assume that the y variable 1.81827 is a typo that should be 1818.27.

The common practice in fittin a log-normal distribution is to fit a normal distribution to a set of logarithmic data:

data = Transpose@{Log10@x, y};


I use the NonlinearModelFit:

nlm = NonlinearModelFit[data, a + b Exp[-(μ - z)^2/(2 σ^2)], {a, b, μ, σ}, z];
Normal@nlm


731.951 + 5607.06 E^(-2055.8 (2.71362 - z)^2)

To plot the data and the fit:

pts = ListPlot[data, Frame -> True];
plot = Plot[Normal[nlm], {z, Min@Log10@x, Max@Log10@x}, Frame -> True];
out = Show[pts, plot, Frame -> True, FrameLabel -> {"log10x", Rotate["y", 270 Degree]}, Frame -> True] The parameters and uncertainties of the fit can be obtained via

table1 = nlm["ParameterTable"] or with another useful command:

param = nlm["BestFitParameters"]


{a -> 731.951, b -> 5607.06, [Mu] -> 2.71362, [Sigma] -> 0.0155953}

which allow, e.g., to get the location of the mean in the initial units:

10^(μ /. param)


517.156

The mean, standard deviation and variance of the log-normal distribution may be obtained with the formulae displayed, e.g., on wikipedia.

• You've fit a curve to the data that has the same shape as a lognormal distribution. But that in no way imparts properties such as mean, variance, etc.
– JimB
Sep 11 '16 at 18:54
• Well, I'm sure of my approach as it is my field of scientific expertise for some time now. Another thing is whether this data really comes from a log-normal distribution - data that I work with span >6 orders of magnitude, so it's quite obvious in that case. The x here, on the other hand, are not very broad so log-normal may not be the right choice. However, this was the OP's request to fit such a distribution. Sep 11 '16 at 19:10
• My comment was very specific to the inferring of any probabilistic characteristics such as mean, variance, cumulative distribution function, probability density function, etc., from the fitted curve. One can't make such inferences as you imply in your last sentence from the data associated with this question.
– JimB
Sep 11 '16 at 20:23