nr.minimizer
Class LevenbergMarquardt

java.lang.Object
  extended by nr.minimizer.LevenbergMarquardt
All Implemented Interfaces:
VecMinimizer

public class LevenbergMarquardt
extends java.lang.Object
implements VecMinimizer

Minimizes a function that generates a Vec by nonlinear least squares minimization of the difference between a given Vec of data and the function results. Uses the method of Levenberg-Marquardt (Numerical Recipes section 15.5). Assumes the sigmas (standard deviations) on the data are identically 1. Since the sigmas are implied, the covariance matrix says nothing about the goodness-of-fit, and this class does not return it. Calculates the Jacobian via symmetric finite differencing. Converges when the computed sum-of-squares changes by less than epsilon.

Author:
Daniel Wachsstock

Constructor Summary
LevenbergMarquardt(Vec data, VecFunction f)
          Create a new instance of LevenbergMarquardt.
 
Method Summary
 double getEpsilon()
          return the relative accuracy parameter
 double minimize(Vec v)
          minimizes a function.
 int numFuncEvals()
          the number of function evaluations it took to converge to the minimum.
 void setEpsilon(double epsilon)
          set the desired relative accuracy parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LevenbergMarquardt

public LevenbergMarquardt(Vec data,
                          VecFunction f)
Create a new instance of LevenbergMarquardt.

Parameters:
data - the data to which to minimize the sum of squared differences.
f - the function that takes a vector of parameters and outputs a vector of simulated data
Method Detail

minimize

public double minimize(Vec v)
Description copied from interface: VecMinimizer
minimizes a function.

Specified by:
minimize in interface VecMinimizer
Parameters:
v - the initial guess for the function. On return, is set to the local minimum.
Returns:
the value of the function at v

numFuncEvals

public int numFuncEvals()
Description copied from interface: VecMinimizer
the number of function evaluations it took to converge to the minimum.

Specified by:
numFuncEvals in interface VecMinimizer
Returns:
the number of function evaluations.

setEpsilon

public void setEpsilon(double epsilon)
Description copied from interface: VecMinimizer
set the desired relative accuracy parameter. Each implementation decides how to interpret this, if at all

Specified by:
setEpsilon in interface VecMinimizer

getEpsilon

public double getEpsilon()
Description copied from interface: VecMinimizer
return the relative accuracy parameter

Specified by:
getEpsilon in interface VecMinimizer