Log-Normal fit of histogram

13 ビュー (過去 30 日間)
De Ar
De Ar 2019 年 10 月 29 日
回答済み: Jeff Miller 2019 年 10 月 29 日
I have a skewed Gaussian distribution in my histogram that I am trying to fit using a log-normal distribution, but my code is giving me a flat fit. Any suggestions to what I am doing wrong?
skewedGauss.png
Attempt
yyaxis left
bar(binLocations, counts);
xlabel('Intensity')
ylabel('Pixel Counts')
% Log-Normal fit
pd = fitdist(counts, 'LogNormal');
pd = makedist('LogNormal', 'mu', pd.mu, 'sigma', pd.sigma);
counts_fit = pdf(pd, binLocations);
counts_fit = counts_fit./sum(counts_fit);
yyaxis right
plot(binLocations, counts_fit, '-', 'LineWidth', 2)
xlim([min(binLocations(:)) max(binLocations(:))])

回答 (1 件)

Jeff Miller
Jeff Miller 2019 年 10 月 29 日
fitdist wants the x values that were tabulated to get the histogram, not the bin counts. From your histogram, it looks like your x should be a vector of length about 10^6 containing numbers in the range 0.4--0.8.

製品


リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by