MATLAB: Fitting a lognormal curve into a histogram
histogrampdf
Hi,
I have a histogram that looks like the one below. I want to fit a lognormal curve (I think a sum of two log normal curves with different sigmas). I am not sure how to do it.
Thanks
Best Answer
% Make up some data. (You should use your real data in place of x.)
x = lognrnd(1,0.3,10000,1);
% Fit the data
parmhat = lognfit(x);
% Plot comparison of the histogram of the data, and the fit
According to the documentation on theGeneralized Extreme Value Distribution particualrly theExamples section, it may or it may not have a zero probability at some value ofx. (It will nevercross zero.) It all depends on what the distribution is for your data. Extend yourxgrid vector in the negative and positive directions and see what it does.
Best Answer