Problem with non-linear fitting models and large numbers

4 ビュー (過去 30 日間)
Anthony
Anthony 2012 年 5 月 1 日
I'm trying to fit some data and having trouble with a general model in the curve fitting toolbox. If I give it data with numbers greater than a million it doesn't even attempt to fit the data and says that the fit converged with 95% confidence between -Inf and Inf. Not very useful.
If I have data = 10, this works. If I have data = 1e9 it completely doesn't. If I have data = 1000, it gives me ~600 though I suspect it would get there eventually if I increased the number of iterations allowed. Interestingly with 1e9 it doesn't even do a single iteration.
This ('a+0*x') is a 'very' simplified version of the function I need to use. I know you would normally use a linear model for fitting a constant (which works fine) but this illustrates the problem. It doesn't work any better if I use a+b*x as the model. I've tried increasing DiffMaxChange with no effect.
Anyone have any ideas? Thanks.
x=(1:10)'; y=10*ones(10,1);
f = fittype('a+0*x'); [c, gof, output] = fit(x, y, f, 'Startpoint', [0], 'MaxIter', 600, 'MaxFunEvals', 2000);
c output
--- Result -------------------------- c =
General model:
c(x) = a+0*x
Coefficients (with 95% confidence bounds):
a = 10 (10, 10)
output =
numobs: 10
numparam: 1
residuals: [10x1 double]
Jacobian: [10x1 double]
exitflag: 1
firstorderopt: 0
iterations: 1
funcCount: 4
cgiterations: 0
algorithm: 'trust-region-reflective'
message: 'Success. Fitting converged to a solution.'
---------------------------------------------
x=(1:10)'; y=1e9*ones(10,1);
f = fittype('a+0*x'); [c, gof, output] = fit(x, y, f, 'Startpoint', [0], 'MaxIter', 600, 'MaxFunEvals', 2000);
c output
--- Result -------------------------- c =
General model:
c(x) = a+0*x
Coefficients (with 95% confidence bounds):
a = 0 (-Inf, Inf)
output =
numobs: 10
numparam: 1
residuals: [10x1 double]
Jacobian: [10x1 double]
exitflag: 1
firstorderopt: 0
iterations: 0
funcCount: 2
cgiterations: 0
algorithm: 'trust-region-reflective'
message: 'Success. Fitting converged to a solution.'

回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by