Initial guess does not change in MATLAB fitting tool

13 views (last 30 days)
I am trying to fit a simple gaussian from very few raw data (a set of x points and y points) with the curve fitting tool implemented in MATLAB (i.e. the simple curve f(x) = a1*exp(-((x-b1)/c1)^2)). It uses the default non linear least squares method.
Now, I want to keep the coefficient c1 fixed, while I let the coefficients a1 and b1 moving, so I can find a good guess for height and centroid. The problem is, whichever algorithm I apply, the coefficient b1 does not move at all from its initial start point, regardless of which point it is! For example, look at the data: evidently, the centroid should go ultimately between x=3.95 and x=4. However, if I put the start point at, for example, 4.1, it will not move from there, and the fitted curve will be evidently wrong.
Even if I put a realistic starting point for b1, for example 3.96, still it will not move. The fit will be more realistic, but I still the algorithm will not have worked properly, since it appears that it does not search at all which should be the final best guess for b1.
Any ideas? Thank you in advance!
  1 Comment
Alex Sha
Alex Sha on 13 Mar 2021
It is because the optimizations algorithms applied in Matlb curve-fitting tool are all local optimization algoritjms, not global optimization algorithms, therefore, the task of guessing the initial start-value is unavoidable, and the reasonable initial value depends on your experience and luck.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 13 Mar 2021
Edited: Matt J on 13 Mar 2021
The order of magnitude of your Y-Data is (~1e-5) is close to the default TolFun stopping parameter. This makes the algorithm prone to early stopping. Try scaling the Y-Data to be ~1e0.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!