How to modify built-in function tolerance for 'lsqcurvefit'?

조회 수: 8 (최근 30일)
Kareemulla Dudekula
Kareemulla Dudekula 2022년 10월 5일
댓글: Kareemulla Dudekula 2022년 10월 6일
Dear All,
I am trying to fit the appended data to a lognormal distribution using lsqcurvefit; however, the function is getting terminated because 'because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance'. My code is as follows (data used for fitting is appended):
**********************************************************************************************************
clc; clear all; close all;
A = xlsread('Curve_fit_data_04102022_3');
xdata = A(:,1); ydata = A(:,2);
plot(xdata,ydata,'ro')
% Supply initial guess
x0 = [2 6];
% Function handle
F = @(x,xdata)(1./xdata/sqrt(2*pi)./log(x(2))).*exp(-0.5.*(log(xdata./x(1))./log(x(2))).^2)
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,xdata,ydata)
************************************************************************************************************
This code throws up an exitflag value of 3 with a resnorm value of 0.2089;
How do I modify the function tolerance such that resnorm is lowered; your inputs are much appreciated.
Regards,
KD

채택된 답변

Torsten
Torsten 2022년 10월 5일
FunctionTolerance and StepTolerance are the parameters in the options-structure you can play with.
  댓글 수: 3
Steven Lord
Steven Lord 2022년 10월 5일
Do you have a reason to believe that the residual norm can be lowered given the form of the equation that you're trying to fit?
If by "lowered the function tolerance" you meant you changed it to something smaller than eps you should read the Tip on this documentation page.
Kareemulla Dudekula
Kareemulla Dudekula 2022년 10월 6일
Do you have a reason to believe that the residual norm can be lowered given the form of the equation that you're trying to fit?
Not at the moment; I had happened to fit a different set of data to the same lognormal distribution and noticed residual norms in the order of e-5. So, I was expecting along the same lines.
If by "lowered the function tolerance" you meant you changed it to something smaller than eps you should read the Tip on this documentation page.
Thanks very much; I shall go through it!
Thanks a ton!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by