MATLAB Answers

Finding fit parameters for x,y data of a lognormal cdf

21 views (last 30 days)
David on 26 Mar 2015
Commented: Alsc on 10 Oct 2019
I have x, y vector data where x = some independent variable of interest and y = cumulative probability. I know the resulting curve represents a lognormal cdf but I'm having trouble finding a way to find the location and scale parameters that correspond to it.
My initial thought was to simply take the cdf, convert it to a pdf by taking p(ii) = y(ii+1) - y(ii), and then use the frequency option of lognfit to find the parameters. I do not get the correct result from this though and was wondering if anyone else had any ideas. Example code is below. Thanks!
if true
% code
X = 1:200;
Y = logncdf(X,4.5,0.1); %4.5 and 0.1 are just for illustration, in reality I don't know these parameters.
for ii = 1:length(X)-1
P(ii) = Y(ii+1)-Y(ii);
P(200) = 1 - Y(end);
fit = lognfit(X,[],[],P)
The location parameter I get from this example is correct, but the scale parameter is 0.

Accepted Answer

David on 26 Mar 2015
I think I answered my own question by going a different route. See code below.
X = 1:200;
Y = logncdf(X,4.5,0.1);
func = @(fit,xdata)logncdf(xdata,fit(1),fit(2));
fit = lsqcurvefit(func,[4 0.3],X,Y)
This gives me fit parameters of
fit =
4.5000 0.1000
Alsc on 10 Oct 2019
Well, I guess I haven't understood this well enough when I have to ask this question, but,
where do I get the goodness of fit and fit parameters from this?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by