When using the cftool, should I use Trust Region or Levenberg-Marquardt?

33 vues (au cours des 30 derniers jours)
Wesley Brown
Wesley Brown le 22 Jan 2020
Commenté : Matt J le 24 Jan 2020
Hello,
I have a data-set that behaves like a sin wave. I need to fit a curve to the data-set using the cftool. In the fit options, there are two algorithms I can choose from: 'trust-region' or 'Levenberg-Marquardt'.
I am trying to figure out the difference between the two algorithms, which algorithm is better, and why. Below is my code, and a screenshot of the curve fitting tool as well as my fit options. Thanks in advance.
%Who: Wesley Brown
%Input: PPP orthometric heights
%Process:Curve fitting
%Output: a1, a2, etc.
clear
format longg
%Time matrix in days
x = [0
90
180
270
360
450
540
630
720
810
900
990
1080
1170
1260
1350
1440];
%Y matrix (change in orthometric height from day 1)
y = [ 0
0.00799999999998136
0.007000000000005
0.00799999999998136
0.000999999999976353
-0.0010000000000332
0.0129999999999768
0.0149999999999864
0.0109999999999673
0.00200000000000955
0
0.0029999999999859
-0.007000000000005
0
-0.00300000000004275
0.00200000000000955
-0.0080000000000382];
cftool(x(:,1),y(:,1));
  5 commentaires
Walter Roberson
Walter Roberson le 22 Jan 2020
Modifié(e) : Walter Roberson le 24 Jan 2020
I am not able to answer the question of which is better or why. The algorithms are described at https://www.mathworks.com/help/optim/ug/equation-solving-algorithms.html
With the data and model you have, your question is like asking whether a chicken or a platypus is a better approximation for a snake.
Walter Roberson
Walter Roberson le 24 Jan 2020
You can get a slightly better fit near
5.84357338824362e-05 2.58183128710864e-05 0.00521135858653424 -0.199178847293523 0.678796516975015 -2.289596742701e-08
These parameters are not unique! The sign of the 3rd one can change, and the 5th one involves semi-periodic behavior about pi/180 apart. The 4th one is periodic as well...
It is still a pretty ugly fit. The model is a terrible one for explaining the data.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 22 Jan 2020
Modifié(e) : Matt J le 22 Jan 2020
You can read here about the relative limitations of the 2 algorithms,
For you, I expect the decision on which algorithm to use will depend on whether you wish to impose bounds on the parameters. Levenberg-Marquardt does not handle bound constraints. It's not really even a decision. If you try to impose bounds, cftool will default to the trust-region algorithm.
  2 commentaires
Wesley Brown
Wesley Brown le 24 Jan 2020
This is great thank you so much! Cheers
Matt J
Matt J le 24 Jan 2020
You are welcome, but please Accept-click the answer if it addresses your question.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by