0

Some weeks ago I started coding the Levenberg-Marquardt algorithm from scratch in Matlab. I'm interested in the polynomial fitting of the data but I haven't been able to achieve the level of accuracy I would like. I'm using a fifth order polynomial after I tried other polynomials and it seemed to be the best option. The algorithm always converges to the same function minimization no matter what improvements I try to implement. So far, I have unsuccessfully added the following features:

  • Geodesic acceleration term as a second order correction
  • Delayed gratification for updating the damping parameter
  • Gain factor to get closer to the Gauss-Newton direction or the steepest descent direction depending on the iteration.
  • Central differences and forward differences for the finite difference method

I don't have experience in nonlinear least squares, so I don't know if there is a way to minimize the residual even more or if there isn't more room for improvement with this method. I attach below an image of the behavior of the polynomial for the last iterations. If I run the code for more iterations, the curve ends up not changing from iteration to iteration. As it is observed, there is a good fit from time = 0 to time = 12. But I'm not able to fix the behavior of the function from time = 12 to time = 20. Any help will be very appreciated.

data points and various fitted curves

Han-Kwang Nienhuys
  • 3,084
  • 2
  • 12
  • 31
Toni
  • 3
  • 1

1 Answers1

0

Fitting a polynomial does not seem to be the best idea. Your data set looks like an exponential transient, with an horizontal asymptote. Forcing a polynomial to that will work very poorly.

I'd rather try with a simple model, such as

A (1 - e^(-at)).

With naked eye, A ~ 15. You should have a look at the values of log(15 - y).

  • I tried some exponential functions but they seem to be very unstable. The residual would blow up after a few iterations if the initial conditions weren't very close to the exact solutions. – Toni Jun 09 '20 at 18:21
  • @Toni: You should have a look at the values of `log(15 - y)`. Don't conclude prematurely. Drop the polynomial model. You can also try a rational fraction. –  Jun 10 '20 at 07:06
  • What do you mean by look at the values of log(15-y). Do you refer to the classical log transformation to fit data to an exponential model in least squares? – Toni Jun 10 '20 at 07:44
  • @toni: you take the ordinate of a data points and you subtract them from the integer 15. Then you take the logarithm (any base) and observe the shape of the curve. You may have some negative values with no logarithm; ignore them for now. –  Jun 10 '20 at 07:57