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 Details

    • LevenbergMarquardt

      public LevenbergMarquardt(double[] parameters, double[] fittedValues, double[] residuals, double sse)
      Creates an instance of a LevenbergMarquardt record class.
      Parameters:
      parameters - the value for the parameters record component
      fittedValues - the value for the fittedValues record component
      residuals - the value for the residuals record component
      sse - the value for the sse record 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 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 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 squares
      maxIter - the maximum number of allowed iterations.
      Returns:
      the sum of squared errors.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • parameters

      public double[] parameters()
      Returns the value of the parameters record component.
      Returns:
      the value of the parameters record component
    • fittedValues

      public double[] fittedValues()
      Returns the value of the fittedValues record component.
      Returns:
      the value of the fittedValues record component
    • residuals

      public double[] residuals()
      Returns the value of the residuals record component.
      Returns:
      the value of the residuals record component
    • sse

      public double sse()
      Returns the value of the sse record component.
      Returns:
      the value of the sse record component