Top Description Fields Constructors Methods
org.apache.commons.math3.optim.nonlinear.vector.jacobian

public abstract Class AbstractLeastSquaresOptimizer

extends JacobianMultivariateVectorOptimizer
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.optim.nonlinear.vector.jacobian.GaussNewtonOptimizer, org.apache.commons.math3.optim.nonlinear.vector.jacobian.LevenbergMarquardtOptimizer
Annotations
@Deprecated
Imports
org.apache.commons.math3.exception.DimensionMismatchException, .TooManyEvaluationsException, org.apache.commons.math3.linear.ArrayRealVector, .RealMatrix, .DiagonalMatrix, .DecompositionSolver, .MatrixUtils, .QRDecomposition, .EigenDecomposition, org.apache.commons.math3.optim.OptimizationData, .ConvergenceChecker, .PointVectorValuePair, org.apache.commons.math3.optim.nonlinear.vector.Weight, .JacobianMultivariateVectorOptimizer, org.apache.commons.math3.util.FastMath

Deprecated

All classes and interfaces in this package are deprecated. The optimizers that were provided here were moved to the org.apache.commons.math3.fitting.leastsquares package (cf. MATH-1008).

Base class for implementing least-squares optimizers. It provides methods for error estimation.
Since
3.1

Field Summary

Modifier and TypeField and Description
private double
cost

Cost value (square root of the sum of the residuals).

private RealMatrix
weightMatrixSqrt

Square-root of the weight matrix.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected double

Returns:

the cost.
computeCost
(double[]
Residuals.
residuals
)

Computes the cost.

public double[][]

Returns:

the covariance matrix.
computeCovariances
(double[]
Model parameters.
params
,
double
Singularity threshold.
threshold
)

Get the covariance matrix of the optimized parameters.

protected double[]

Returns:

the residuals.
computeResiduals
(double[]
Value of the the objective function. This is the value returned from a call to computeObjectiveValue (whose array argument contains the model parameters).
objectiveValue
)

Computes the residuals.

public double[]

Returns:

an estimate of the standard deviation of the optimized parameters
computeSigma
(double[]
Model parameters.
params
,
double
Singularity threshold (see computeCovariances).
covarianceSingularityThreshold
)

Computes an estimate of the standard deviation of the parameters.

protected RealMatrix

Returns:

the weighted Jacobian: W1/2 J.
computeWeightedJacobian
(double[]
Model parameters at which to compute the Jacobian.
params
)

Computes the weighted Jacobian matrix.

public double

Returns:

chi-square value
getChiSquare
()

Get a Chi-Square-like value assuming the N residuals follow N distinct normal distributions centered on 0 and whose variances are the reciprocal of the weights.

public double

Returns:

the RMS value.
getRMS
()

Gets the root-mean-square (RMS) value.

public RealMatrix

Returns:

the square-root of the weight matrix.
getWeightSquareRoot
()

Gets the square-root of the weight matrix.

public PointVectorValuePair

Returns:

a point/value pair that satisfies the convergence criteria.
optimize
(OptimizationData...
Optimization data. In addition to those documented in JacobianMultivariateVectorOptimizer, this method will register the following data:
optData
)

Overrides org.apache.commons.math3.optim.nonlinear.vector.JacobianMultivariateVectorOptimizer.optimize.

Stores data and performs the optimization.

protected void
parseOptimizationData(OptimizationData...
Optimization data. The following data will be looked for:
optData
)

Overrides org.apache.commons.math3.optim.nonlinear.vector.JacobianMultivariateVectorOptimizer.parseOptimizationData.

Scans the list of (required and optional) optimization data that characterize the problem.

protected void
setCost(double
Cost value.
cost
)

Sets the cost.

private RealMatrix

Returns:

the square-root of the weight matrix.
squareRoot
(RealMatrix
Symmetric, positive-definite (weight) matrix.
m
)

Computes the square-root of the weight matrix.

Inherited from org.apache.commons.math3.optim.nonlinear.vector.JacobianMultivariateVectorOptimizer:
computeJacobian

Field Detail

costback to summary
private double cost

Cost value (square root of the sum of the residuals).

weightMatrixSqrtback to summary
private RealMatrix weightMatrixSqrt

Square-root of the weight matrix.

Constructor Detail

AbstractLeastSquaresOptimizerback to summary
protected AbstractLeastSquaresOptimizer(ConvergenceChecker<PointVectorValuePair> checker)
Parameters
checker:ConvergenceChecker<PointVectorValuePair>

Convergence checker.

Method Detail

computeCostback to summary
protected double computeCost(double[] residuals)

Computes the cost.

Parameters
residuals:double[]

Residuals.

Returns:double

the cost.

See Also
computeResiduals(double[])
computeCovariancesback to summary
public double[][] computeCovariances(double[] params, double threshold)

Get the covariance matrix of the optimized parameters.
Note that this operation involves the inversion of the JTJ matrix, where J is the Jacobian matrix. The threshold parameter is a way for the caller to specify that the result of this computation should be considered meaningless, and thus trigger an exception.

Parameters
params:double[]

Model parameters.

threshold:double

Singularity threshold.

Returns:double[][]

the covariance matrix.

Exceptions
SingularMatrixException:
if the covariance matrix cannot be computed (singular problem).
computeResidualsback to summary
protected double[] computeResiduals(double[] objectiveValue)

Computes the residuals. The residual is the difference between the observed (target) values and the model (objective function) value. There is one residual for each element of the vector-valued function.

Parameters
objectiveValue:double[]

Value of the the objective function. This is the value returned from a call to computeObjectiveValue (whose array argument contains the model parameters).

Returns:double[]

the residuals.

Exceptions
DimensionMismatchException:
if params has a wrong length.
computeSigmaback to summary
public double[] computeSigma(double[] params, double covarianceSingularityThreshold)

Computes an estimate of the standard deviation of the parameters. The returned values are the square root of the diagonal coefficients of the covariance matrix, sd(a[i]) ~= sqrt(C[i][i]), where a[i] is the optimized value of the i-th parameter, and C is the covariance matrix.

Parameters
params:double[]

Model parameters.

covarianceSingularityThreshold:double

Singularity threshold (see computeCovariances).

Returns:double[]

an estimate of the standard deviation of the optimized parameters

Exceptions
SingularMatrixException:
if the covariance matrix cannot be computed.
computeWeightedJacobianback to summary
protected RealMatrix computeWeightedJacobian(double[] params)

Computes the weighted Jacobian matrix.

Parameters
params:double[]

Model parameters at which to compute the Jacobian.

Returns:RealMatrix

the weighted Jacobian: W1/2 J.

Exceptions
DimensionMismatchException:
if the Jacobian dimension does not match problem dimension.
getChiSquareback to summary
public double getChiSquare()

Get a Chi-Square-like value assuming the N residuals follow N distinct normal distributions centered on 0 and whose variances are the reciprocal of the weights.

Returns:double

chi-square value

getRMSback to summary
public double getRMS()

Gets the root-mean-square (RMS) value. The RMS the root of the arithmetic mean of the square of all weighted residuals. This is related to the criterion that is minimized by the optimizer as follows: If c if the criterion, and n is the number of measurements, then the RMS is sqrt (c/n).

Returns:double

the RMS value.

getWeightSquareRootback to summary
public RealMatrix getWeightSquareRoot()

Gets the square-root of the weight matrix.

Returns:RealMatrix

the square-root of the weight matrix.

optimizeback to summary
public PointVectorValuePair optimize(OptimizationData... optData) throws TooManyEvaluationsException

Overrides org.apache.commons.math3.optim.nonlinear.vector.JacobianMultivariateVectorOptimizer.optimize.

Doc from org.apache.commons.math3.optim.nonlinear.vector.JacobianMultivariateVectorOptimizer.optimize.

Stores data and performs the optimization.

The list of parameters is open-ended so that sub-classes can extend it with arguments specific to their concrete implementations.

When the method is called multiple times, instance data is overwritten only when actually present in the list of arguments: when not specified, data set in a previous call is retained (and thus is optional in subsequent calls).

Important Note

Subclasses must override parseOptimizationData(OptimizationData[]) if they need to register their own options; but then, they must also call super.parseOptimizationData(optData) within that method.

Parameters
optData:OptimizationData[]

Optimization data. In addition to those documented in JacobianMultivariateVectorOptimizer, this method will register the following data:

Returns:PointVectorValuePair

a point/value pair that satisfies the convergence criteria.

Annotations
@Override
Exceptions
TooManyEvaluationsException:
if the maximal number of evaluations is exceeded.
DimensionMismatchException:
if the initial guess, target, and weight arguments have inconsistent dimensions.
parseOptimizationDataback to summary
protected void parseOptimizationData(OptimizationData... optData)

Overrides org.apache.commons.math3.optim.nonlinear.vector.JacobianMultivariateVectorOptimizer.parseOptimizationData.

Scans the list of (required and optional) optimization data that characterize the problem. If the weight matrix is specified, the weightMatrixSqrt field is recomputed.

Parameters
optData:OptimizationData[]

Optimization data. The following data will be looked for:

Annotations
@Override
setCostback to summary
protected void setCost(double cost)

Sets the cost.

Parameters
cost:double

Cost value.

squareRootback to summary
private RealMatrix squareRoot(RealMatrix m)

Computes the square-root of the weight matrix.

Parameters
m:RealMatrix

Symmetric, positive-definite (weight) matrix.

Returns:RealMatrix

the square-root of the weight matrix.