public class LevenbergMarquardtSolver extends Object implements FunctionFitter
FitFunction.val(double[], double[])
and FitFunction.grad(double[], double[], int)
methods to operate with this
solver.
It was adapted and stripped from jplewis (www.idiom.com/~zilla) and released under the GPL. There are various small tweaks for robustness and speed.
Constructor and Description |
---|
LevenbergMarquardtSolver()
Creates a new Levenberg-Marquardt solver for least-square curve fitting problems,
with default parameters set to:
lambda = 1e-3
epsilon = 1e-1
maxIter = 300
|
LevenbergMarquardtSolver(int maxIteration,
double lambda,
double termEpsilon)
Creates a new Levenberg-Marquardt solver for least-square curve fitting problems.
|
Modifier and Type | Method and Description |
---|---|
static double |
chiSquared(double[][] x,
double[] a,
double[] y,
FitFunction f)
Calculate the current sum-squared-error
|
void |
fit(double[][] x,
double[] y,
double[] a,
FitFunction f)
Minimizes
E = sum {(y[k] - f(x[k],a)) }^2 . |
static int |
solve(double[][] x,
double[] a,
double[] y,
FitFunction f,
double lambda,
double termepsilon,
int maxiter)
Minimize E = sum {(y[k] - f(x[k],a)) }^2
Note that function implements the value and gradient of f(x,a),
NOT the value and gradient of E with respect to a!
|
String |
toString() |
public LevenbergMarquardtSolver(int maxIteration, double lambda, double termEpsilon)
lambda
- blend between steepest descent (lambda high) and
jump to bottom of quadratic (lambda zero). Start with 0.001.termEpsilon
- termination accuracy (0.01)maxIteration
- stop and return after this many iterations if not donepublic LevenbergMarquardtSolver()
lambda = 1e-3
epsilon = 1e-1
maxIter = 300
public void fit(double[][] x, double[] y, double[] a, FitFunction f) throws Exception
FunctionFitter
E = sum {(y[k] - f(x[k],a)) }^2
.
Note that function implements the value and gradient of f(x,a),
NOT the value and gradient of E with respect to a!fit
in interface FunctionFitter
x
- array of domain points, each may be multidimensional.
(For instance, for 2D data, provides a double array of N double arrays
of 2 elements: x & y.)y
- corresponding array of values.a
- the parameters/state of the model. Is updated by the call.f
- the function to fit on the domain points.Exception
- if the fitting process meets a numerical problem.public static final double chiSquared(double[][] x, double[] a, double[] y, FitFunction f)
public static final int solve(double[][] x, double[] a, double[] y, FitFunction f, double lambda, double termepsilon, int maxiter) throws Exception
x
- array of domain points, each may be multidimensionaly
- corresponding array of valuesa
- the parameters/state of the modellambda
- blend between steepest descent (lambda high) and
jump to bottom of quadratic (lambda zero). Start with 0.001.termepsilon
- termination accuracy (0.01)maxiter
- stop and return after this many iterations if not doneException
Copyright © 2015–2022 ImgLib2. All rights reserved.