Package smile.math
Class LevenbergMarquardt
java.lang.Object
smile.math.LevenbergMarquardt
The Levenberg–Marquardt algorithm.
The Levenberg–Marquardt algorithm (LMA), also known as the Damped
least-squares method, is used to solve non-linear least squares
problems for generic curve-fitting problems. However,
as with many fitting algorithms, the LMA finds only a local minimum,
which is not necessarily the global minimum. The LMA interpolates
between the Gauss–Newton algorithm (GNA) and the method of gradient
descent. The LMA is more robust than the GNA, which means that in
many cases it finds a solution even if it starts very far off the
final minimum. For well-behaved functions and reasonable starting
parameters, the LMA tends to be a bit slower than the GNA. LMA can
also be viewed as Gauss–Newton using a trust region approach.
-
Field Summary
Modifier and TypeFieldDescriptionfinal double[]
The fitted values.final double[]
The fitted parameters.final double[]
The residuals.final double
The sum of squares due to error. -
Method Summary
Modifier and TypeMethodDescriptionstatic LevenbergMarquardt
fit
(DifferentiableMultivariateFunction func, double[][] x, double[] y, double[] p) Fits the nonlinear least squares.static LevenbergMarquardt
fit
(DifferentiableMultivariateFunction func, double[][] x, double[] y, double[] p, double stol, int maxIter) Fits the nonlinear least squares.static LevenbergMarquardt
fit
(DifferentiableMultivariateFunction func, double[] x, double[] y, double[] p) Fits the nonlinear least squares.static LevenbergMarquardt
fit
(DifferentiableMultivariateFunction func, double[] x, double[] y, double[] p, double stol, int maxIter) Fits the nonlinear least squares.
-
Field Details
-
parameters
public final double[] parametersThe fitted parameters. -
fittedValues
public final double[] fittedValuesThe fitted values. -
residuals
public final double[] residualsThe residuals. -
sse
public final double sseThe sum of squares due to error.
-
-
Method Details
-
fit
public static LevenbergMarquardt fit(DifferentiableMultivariateFunction func, double[] x, double[] y, double[] p) Fits the nonlinear least squares.- Parameters:
func
- the curve function.x
- independent variable.y
- the observations.p
- the initial parameters.- Returns:
- the sum of squared errors.
-
fit
public static LevenbergMarquardt fit(DifferentiableMultivariateFunction func, double[] x, double[] y, double[] p, double stol, int maxIter) Fits the nonlinear least squares.- Parameters:
func
- the curve function. Of the input variable x, the first d elements are hyper-parameters to be fit. The rest is the independent variable.x
- independent variable.y
- the observations.p
- the initial parameters.stol
- the scalar tolerances on fractional improvement in sum of squaresmaxIter
- the maximum number of allowed iterations.- Returns:
- the sum of squared errors.
-
fit
public static LevenbergMarquardt fit(DifferentiableMultivariateFunction func, double[][] x, double[] y, double[] p) Fits the nonlinear least squares.- Parameters:
func
- the curve function.x
- independent variables.y
- the observations.p
- the initial parameters.- Returns:
- the sum of squared errors.
-
fit
public static LevenbergMarquardt fit(DifferentiableMultivariateFunction func, double[][] x, double[] y, double[] p, double stol, int maxIter) Fits the nonlinear least squares.- Parameters:
func
- the curve function. Of the input variable x, the first d elements are hyper-parameters to be fit. The rest is the independent variable.x
- independent variables.y
- the observations.p
- the initial parameters.stol
- the scalar tolerances on fractional improvement in sum of squaresmaxIter
- the maximum number of allowed iterations.- Returns:
- the sum of squared errors.
-