Levenberg-Marquardt

 Levenberg-Marquardt a.k.a. damped least-squares method in which you fit any arbitrary model function to observed data points, but requires the solution of the systems of nonlinear equations for determining the optimal model parameters.


The way it works is you first calculate the merit function for an initial set of parameters and have the dimensionless scale factor (lambda) preferably small, so the system allows for the parameter corrections to be determined close to the minimum.

Then calculate the coefficients/curvature matrix elements c_kj, b_k and solve the linear system for the parameter corrections so you can evaluate the merit function for the corrected parameters.


To finish it off:

If the evaluated merit function is greater equal than the original merit function, then increase the dimensionless scale factor by a factor of 10 and recalculate the coefficients.


If the evaluated merit function is smaller than the original merit function, then decrease the dimensionless scale factor by a factor of 10 and revert the corrections.


Coded in C++/Python:


Derive function evaluates the derivatives of the model function at a point concerning parameters.

Merit evaluates the merit function and the matrices c and b for the function f.