how to select proper parameters for "opt.StartPoint" ?

3 ビュー (過去 30 日間)
vx2008
vx2008 2014 年 9 月 22 日
コメント済み: vx2008 2014 年 9 月 22 日
I want to fit some data as below code:
if true
p=fittype('a+k*b/(b+x)','independent','x');
opt=fitoptions(p);
opt.StartPoint=[1e-8,0.5,1e-8];
f=fit(x,y,p,opt)
Y=f(x);
corrcoef(y,Y)
end
when I delete the code "opt=fitoptions(p);opt.StartPoint=[1e-8,0.5,1e-8];", I get the value of "a", "b", and "k" as below:
General model:
f(x) = a+k*b/(b+x)
Coefficients:
a = 6.611e-08
b = 0.4854
k = 5.829e-08
then I add the code "opt=fitoptions(p);opt.StartPoint=[1e-8,0.5,1e-8];", and then I get the values as below:
General model:
f(x) = a+k*b/(b+x)
Coefficients:
a = 1e-08
b = 0.5
k = 1e-08
I don't know why "a","b" and "k" never change? and how shall I set "opt.StartPoint" properly?
thank you!

回答 (1 件)

Matt J
Matt J 2014 年 9 月 22 日
編集済み: Matt J 2014 年 9 月 22 日
It's possible the solution is simply unstable because you have bad data. For example, if all your y-data are very close to zero (as compared to x), then clearly any solution with a and b*k close to zero will give a reasonable fit.
If it is a matter of the initial guess, though, you might be able to generate a better one by re-arranging the model equation in linear form. In other words, starting with the model equation,
y=a +b*k/(x+b)
re-arrange as,
a*x -b*y + a*b + b*k =x.*y
and re-parametrize this as
A*x + B*y + C =x.*y
Solve the linear equations for [A;B;C],
ABC = [x(:),y(:), ones(length(x),1)]\[x(:).*y(:)];
A=ABC(1);
B=ABC(2);
C=ABC(3);
a=A;
b=-B;
k=(C-a*b)/b;
Now, use this preliminary solution as a start point for the fit,
opt.StartPoint=[a,b,k];

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by