levenberg-marquardt
Curve fitting method in javascript
Installation
$ npm install ml-levenberg-marquardt
This algorithm is based on the article Brown, Kenneth M., and J. E. Dennis. "Derivative free analogues of the Levenberg-Marquardt and Gauss algorithms for nonlinear least squares approximation." Numerische Mathematik 18.4 (1971): 289-297.
In order to get a general idea of the problem you could also check the Wikipedia article.
Example
import LM from 'ml-levenberg-marquardt';
function sinFunction([a, b]) {
return (t) => a * Math.sin(b * t);
}
let data = {
x: [
],
y: [
]
};
let initialValues = [
];
const options = {
damping: 1.5,
initialValues: initialValues,
gradientDifference: 10e-2,
maxIterations: 100,
errorTolerance: 10e-3
};
let fittedParams = LM(data, sinFunction, options);
Or test it in Runkit
License
MIT