Fit Lognormal function on already generated bins

3 visualizzazioni (ultimi 30 giorni)
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?

Risposte (2)

Jeff Miller
Jeff Miller il 4 Mag 2019
Cupid has a command called EstChiSq that will do this. See https://github.com/milleratotago/Cupid

Star Strider
Star Strider il 4 Mag 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));

Community Treasure Hunt

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

Start Hunting!

Translated by