Re: lsqcurvefit bounds influence fitting result



Without analyzing your particular function, I can say that many, perhaps most, realistic fitting problems have many local minima. Changing the bounds causes lsqcurvefit to reach different local answers (minima). If you want a global minimum, you have to take extra steps.

If you have a Global Optimization Toolbox license, you can use MultiStart to search for a global minimum very easily. Even without MultiStart, you can write a program of your own to take a variety of start points and collect the results.

Good luck,

Alan Weiss
MATLAB mathematical toolbox documentation

On 3/17/2011 1:37 PM, Philipp Steffen wrote:
Hallo,
I have been using lsqcurvefit for a while to fit measured data to a
gaussian function with an initial constant part to extract parameters
that describe the constant part as well as the gaussian shape of the curve.
Now I realized, that this is quite sensitive to the upper and lower
bound. I need to set the lower bound to be >0. In principle I dont need
a upper bound but the results of the fit vary quite drastically
depending on if I put ub=[], ub=[1,1,1] or ub=[10,10,10].
In my dataset for example, ub=[10,10,10] yields the parameter
beta=0.0000 0.1995 1.3786 (resnorm=0.1626)
when I put ub=[1,1,1] i get:
beta=0.4395 0.2434 1.0000 (resnorm=0.2531)
and with ub=[]:
beta=2.6643 0.4244 0.6430 (resnorm=1.4990)
Clearly the fit using ub=[10,10,10] is the best. Why is this? Why do the
boundaries influence the fit in this way?
I appreciate any hints and comments and hope that someone can help me to
solve this issue. Basically, I don't want to fix the bounds to a value,
since I would like to keep the function as flexible as possible.

Here is my code:

radius: 48 double values
RP: 48 double values

beta0(1)=0.4;
beta0(2)=0.79;
beta0(3)=0.8;
beta = lsqcurvefit(@func,beta0,radius,RP,[realmin,realmin,realmin],[]);

Function:
function [yhat] = func(b, radius) for i=1:length(radius),
if (radius(i) < b(1)),
yhat(i) = b(2);
else
yhat(i) = 1 - ((1-b(2))*exp(-0.5*(((radius(i)-b(1))^2)/(b(3)^2))));
end
end;
yhat=yhat';
end


Thanks a lot,

Philipp

.



Relevant Pages

  • Re: Fitting Functions
    ... >statistical techniques to give the probability that the fit is the correct ... of local minima in parameter space. ... selecting the parameters that minimize chi-square. ... that the best fit, even if there's a precipice just over the next ridge. ...
    (sci.physics)
  • Re: Nonlinear Least-Squares curve-fitting
    ... You are only correct if the function you are trying to fit is linear. ... However, if the function that one is trying to fit is nonlinear, more ... function more complicated and also cause it to have more local minima. ... -- Reef Fish Bob. ...
    (sci.stat.math)
  • Re: Fitting LSQCURVEFIT
    ... I have been using LSQCURVEFIT for one set of model and actual data by ... varying TH,F and Z and want to fit it to experimental data, where F ... The model data are the same metrics as the experimental data simulated ...
    (comp.soft-sys.matlab)
  • Fitting LSQCURVEFIT
    ... I have been using LSQCURVEFIT for one set of model and actual data by ... but don't know how to input multiple data ... varying TH,F and Z and want to fit it to experimental data, where F ... Should I create a sum of the differences function of all the data as ...
    (comp.soft-sys.matlab)
  • transistor parameter optimization-lsqcurvefit
    ... I am having problems with the lsqcurvefit function. ... the equations which will help me to fit the mathematical model to ... The mathematical model that I implemented in matlab is correct ...
    (comp.soft-sys.matlab)