Search code examples
matlabfunction-fitting

How to interpret matlab lsqnonlin output display?


I am fitting a function with different number of floating parameters using lsqnonlin in matlab.

The first fitting produces better fitting, resnorm of 2.5. matlab displays:

                                         Norm of      First-order 
 Iteration  Func-count     f(x)          step          optimality
     0         24         17492.8                      9.07e+05
     1         48          143.52       0.106514       2.14e+04      
     2         72         28.1836       0.322225       9.21e+03      
     3         96         8.22318       0.190289            471      
     4        120         4.64683       0.106685            469      
     5        144         4.21385       0.110651           50.6      
     6        168         3.84595       0.132576           6.57      
     7        192         3.80318      0.0785982          0.574      
     8        216         3.80298     0.00714585         0.0696      
     9        240         3.80298    8.99227e-05         0.0165

The 2nd fitting's resnorm is 3.6. matlab displays:

                                         Norm of      First-order 
 Iteration  Func-count     f(x)          step          optimality
     0         38         17492.8                      9.07e+05
     1         76         158.945       0.112853       3.12e+04      
     2        114         31.4081       0.296493       9.11e+03      
     3        152         8.51237       0.171055            627      
     4        190         4.73721       0.485675       1.01e+03      
     5        228         4.25786       0.268581            121      
     6        266         3.82232       0.424431           12.9      
     7        304         3.67385       0.483489             13      
     8        342         3.65582       0.290754             21      
     9        380         3.64699       0.331376           25.9      
    10        418         3.64327       0.237147             16      
    11        456         3.64078       0.236815           13.3      
    12        494         3.63925       0.203176           9.54      
    13        532         3.63819       0.186138           7.32      
    14        570         3.63747       0.165213           5.52      
    15        608         3.63697       0.148463            4.2      
    16        646         3.63663       0.132661           3.17      
    17        684          3.6364       0.118115           2.35      
    18        722         3.63624       0.102959           1.73      
    19        760         3.63616      0.0842739            1.2      
    20        798         3.63612      0.0589477          0.731      
    21        836         3.63611      0.0309845          0.391      
    22        874          3.6361      0.0119255          0.192   

Both these fittings: "lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the default value of the function tolerance."

How do I interpret the displays for fitting result, without looking at resnorm?

From what I can see, the 1st fittings "norm of step" is much less. The final result of f(x) and first-order optimality are similar.

What does each column mean? How do I interpret them?


Solution

  • From the mathworks website:

    Iteration - The iteration number.

    Func Count - Number of function evaluations.

    f(x) - The value of the function at x.

    Norm of step - Size of the current step.

    First-Order Optimality - First-order optimality is a measure of how close a point x is to optimal.

    What you want to look at is the fact that the first order optimality -> 0 (and your residuals -> 0 too), as this will indicate your algorithm is converging or has converged on an optimal solution. The first fitting you must have provided a better guess or used a better algorithm, because it converged in only 9 iterations, whereas your second fitting converged in 22.