Fit Lognormal function on already generated bins

Hi, My code itself generates the bins and frequency of each bin and I want to simply fit Lognormal distribution function on this already generated distribution. The problem is that, the available Matlab commands such as fitdist need to generate bins and frequencies and then fit Lognormal function. So, how can I remove the first step and simply fit Lognormal function on my own distribution data?

Antworten (2)

Jeff Miller
Jeff Miller am 4 Mai 2019

0 Stimmen

Cupid has a command called EstChiSq that will do this. See https://github.com/milleratotago/Cupid
Star Strider
Star Strider am 4 Mai 2019
Another option is to fit the CDF to estimate the parameters:
x = lognrnd(0.5, 0.75, 1, 100); % Create Data
[k,e] = histcounts(x, 50); % Histogram
p = cumsum(k)/sum(k); % Cumulative Probabilities
c = diff(e(1:2))/2 + e(1:end-1); % Bin Centers
B = fminsearch(@(b) norm(p - logncdf(c,b(1),b(2))), rand(2,1)); % Estimate Parameters
Here B(1) is μ and B(2) is σ. That generates a reasonably accurate estimate. If you want confidence limits on the estimated parameters, use nlinfit and nlparci, with your ‘c’ and ‘p’ vectors, the objective function being:
objfcn = @(b,c) logncdf(c,b(1),b(2));

Gefragt:

am 3 Mai 2019

Beantwortet:

am 4 Mai 2019

Community Treasure Hunt

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

Start Hunting!

Translated by