Record Class LevenbergMarquardt
java.lang.Object
java.lang.Record
smile.math.LevenbergMarquardt
- Record Components:
parameters- The fitted parameters.fittedValues- The fitted values.residuals- The residuals.sse- The sum of squares due to error.
public record LevenbergMarquardt(double[] parameters, double[] fittedValues, double[] residuals, double sse)
extends Record
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.
-
Constructor Summary
ConstructorsConstructorDescriptionLevenbergMarquardt(double[] parameters, double[] fittedValues, double[] residuals, double sse) Creates an instance of aLevenbergMarquardtrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static LevenbergMarquardtfit(DifferentiableMultivariateFunction func, double[][] x, double[] y, double[] p) Fits the nonlinear least squares.static LevenbergMarquardtfit(DifferentiableMultivariateFunction func, double[][] x, double[] y, double[] p, double stol, int maxIter) Fits the nonlinear least squares.static LevenbergMarquardtfit(DifferentiableMultivariateFunction func, double[] x, double[] y, double[] p) Fits the nonlinear least squares.static LevenbergMarquardtfit(DifferentiableMultivariateFunction func, double[] x, double[] y, double[] p, double stol, int maxIter) Fits the nonlinear least squares.double[]Returns the value of thefittedValuesrecord component.final inthashCode()Returns a hash code value for this object.double[]Returns the value of theparametersrecord component.double[]Returns the value of theresidualsrecord component.doublesse()Returns the value of thesserecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
LevenbergMarquardt
public LevenbergMarquardt(double[] parameters, double[] fittedValues, double[] residuals, double sse) Creates an instance of aLevenbergMarquardtrecord class.- Parameters:
parameters- the value for theparametersrecord componentfittedValues- the value for thefittedValuesrecord componentresiduals- the value for theresidualsrecord componentsse- the value for thesserecord component
-
-
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 hyperparameters 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 hyperparameters 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.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
parameters
public double[] parameters()Returns the value of theparametersrecord component.- Returns:
- the value of the
parametersrecord component
-
fittedValues
public double[] fittedValues()Returns the value of thefittedValuesrecord component.- Returns:
- the value of the
fittedValuesrecord component
-
residuals
-
sse
-