Curve fitting algorithm

levenbergMarquardt(data: {x: Array<number>, y: Array<number>}, parameterizedFunction: function, options: object?): {parameterValues: Array<number>, parameterError: number, iterations: number}
data ({x: Array<number>, y: Array<number>}) Array of points to fit in the format [x1, x2, ... ] , [y1, y2, ... ]
parameterizedFunction (function) The parameters and returns a function with the independent variable as a parameter
options (object? = {}) Options object
Name Description
options.weights (number | array) (default 1) weighting vector, if the length does not match with the number of data points, the vector is reconstructed with first value.
options.damping number (default 1e-2) Levenberg-Marquardt parameter, small values of the damping parameter λ result in a Gauss-Newton update and large values of λ result in a gradient descent update
options.dampingStepDown number (default 9) factor to reduce the damping (Levenberg-Marquardt parameter) when there is not an improvement when updating parameters.
options.dampingStepUp number (default 11) factor to increase the damping (Levenberg-Marquardt parameter) when there is an improvement when updating parameters.
options.improvementThreshold number (default 1e-3) the threshold to define an improvement through an update of parameters
options.gradientDifference (number | array) (default 10e-2) The step size to approximate the jacobian matrix
options.centralDifference boolean (default false) If true the jacobian matrix is approximated by central differences otherwise by forward differences
options.minValues Array<number>? Minimum allowed values for parameters
options.maxValues Array<number>? Maximum allowed values for parameters
options.initialValues Array<number>? Array of initial parameter values
options.maxIterations number (default 100) Maximum of allowed iterations
options.errorTolerance number (default 10e-3) Minimum uncertainty allowed for each point
{parameterValues: Array<number>, parameterError: number, iterations: number}: