E nvironment for Deve L oping K DD-Applications Supported by I ndex-Structures

## de.lmu.ifi.dbs.elki.math.linearalgebra.fitting Class LevenbergMarquardtMethod

```java.lang.Object
de.lmu.ifi.dbs.elki.math.linearalgebra.fitting.LevenbergMarquardtMethod
```

`public class LevenbergMarquardtMethodextends Object`

Function parameter fitting using Levenberg-Marquardt method Implemented mostly based on: Numerical Recipes In C: The Art Of Scientific Computing ISBN 0-521-43108-5 Press, W.H. and Teukolsky, S.A. and Vetterling, W.T. and Flannery, B.P. Cambridge University Press, Cambridge, Mass, 1992

Author:
Erich Schubert

Field Summary
`private  double[][]` `alpha`
Working space for alphas
`private  double[]` `beta`

`private  double` `chisq`
Chi-Squared information for parameters
`private  double[][]` `covmat`
Working space for covariance matrix
`private  double[]` `deltaparams`

`private  boolean[]` `dofit`
Which parameters to fit
` FittingFunction` `func`
Function to fit to
`private  double` `lambda`
Lambda (refinement step size)
` int` `maxruns`
Maximum number of iterations in run()
` int` `maxsmall`
Maximum number of small improvements (stopping condition)
`private  int` `numfit`
Number of parameters to fit
`private  int` `numparams`
Number of parameters
`private  double[]` `params`
Parameters to use in fitting
`private  double[]` `paramstry`
More working buffers
`private  double[]` `s`

` double` `small`
"Small value" condition for stopping
`private  double[]` `x`
Data to fit the function to
`private  double[]` `y`

Constructor Summary
```LevenbergMarquardtMethod(FittingFunction func, double[] params, boolean[] dofit, double[] x, double[] y, double[] s)```
Function fitting using Levenberg-Marquardt Method.

Method Summary
` double` `getChiSq()`
Get current ChiSquared (squared error sum)
` double[][]` `getCovmat()`
Get the final covariance matrix.
` double[]` `getParams()`
Get current parameters.
` void` `iterate()`
Perform an iteration of the approximation loop.
` void` `run()`
Iterate until convergence, at most 100 times.
`private  double` `simulateParameters(double[] curparams)`
Compute new chisquared error This function also modifies the alpha and beta matrixes!

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### func

`public FittingFunction func`
Function to fit to

### x

`private double[] x`
Data to fit the function to

### y

`private double[] y`

### s

`private double[] s`

### numparams

`private int numparams`
Number of parameters

### params

`private double[] params`
Parameters to use in fitting

### chisq

`private double chisq`
Chi-Squared information for parameters

### numfit

`private int numfit`
Number of parameters to fit

### dofit

`private boolean[] dofit`
Which parameters to fit

### covmat

`private double[][] covmat`
Working space for covariance matrix

### alpha

`private double[][] alpha`
Working space for alphas

### lambda

`private double lambda`
Lambda (refinement step size)

### paramstry

`private double[] paramstry`
More working buffers

### beta

`private double[] beta`

### deltaparams

`private double[] deltaparams`

### maxruns

`public int maxruns`
Maximum number of iterations in run()

### maxsmall

`public int maxsmall`
Maximum number of small improvements (stopping condition)

### small

`public double small`
"Small value" condition for stopping

Constructor Detail

### LevenbergMarquardtMethod

```public LevenbergMarquardtMethod(FittingFunction func,
double[] params,
boolean[] dofit,
double[] x,
double[] y,
double[] s)```
Function fitting using Levenberg-Marquardt Method.

Parameters:
`func` - Function to fit to
`x` - Measurement points
`y` - Actual function values
`s` - Confidence / Variance in measurement data
`params` - Initial parameters
`dofit` - Flags on which parameters to optimize
Method Detail

### simulateParameters

`private double simulateParameters(double[] curparams)`
Compute new chisquared error This function also modifies the alpha and beta matrixes!

Parameters:
`curparams` - Parameters to use in computation.
Returns:
new chi squared

### iterate

`public void iterate()`
Perform an iteration of the approximation loop.

### getCovmat

`public double[][] getCovmat()`
Get the final covariance matrix. Parameters that were not to be optimized are filled with zeros.

Returns:
covariance matrix for all parameters

### getParams

`public double[] getParams()`
Get current parameters.

Returns:
parameters

### getChiSq

`public double getChiSq()`
Get current ChiSquared (squared error sum)

Returns:
error measure

### run

`public void run()`
Iterate until convergence, at most 100 times.

 Release 0.2 (2009-07-06_1820)