Package smile.math

# Class LevenbergMarquardt

java.lang.Object
smile.math.LevenbergMarquardt

public class LevenbergMarquardt extends Object
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

Fields
Modifier and Type
Field
Description
`final double[]`
`fittedValues`
The fitted values.
`final double[]`
`parameters`
The fitted parameters.
`final double[]`
`residuals`
The residuals.
`final double`
`sse`
The sum of squares due to error.
• ## Method Summary

Modifier and Type
Method
Description
`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.
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ## Field Details

• ### parameters

public final double[] parameters
The fitted parameters.
• ### fittedValues

public final double[] fittedValues
The fitted values.
• ### residuals

public final double[] residuals
The residuals.
• ### sse

public final double sse
The 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 squares
`maxIter` - 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 squares
`maxIter` - the maximum number of allowed iterations.
Returns:
the sum of squared errors.