Top Description Inners Methods
org.apache.commons.math3.fitting.leastsquares

public Interface LeastSquaresProblem

extends OptimizationProblem<LeastSquaresProblem.Evaluation>
Known Direct Implementers
org.apache.commons.math3.fitting.leastsquares.LeastSquaresAdapter, org.apache.commons.math3.fitting.leastsquares.LeastSquaresFactory.LocalLeastSquaresProblem
Imports
org.apache.commons.math3.linear.RealMatrix, .RealVector, org.apache.commons.math3.optim.OptimizationProblem

The data necessary to define a non-linear least squares problem.

Includes the observed values, computed model function, and convergence/divergence criteria. Weights are implicit in Evaluation#getResiduals() and Evaluation#getJacobian().

Instances are typically either created progressively using a builder or created at once using a factory.

Since
3.3
See Also
LeastSquaresBuilder, LeastSquaresFactory, LeastSquaresAdapter

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
LeastSquaresProblem.Evaluation

An evaluation of a LeastSquaresProblem at a particular point.

Method Summary

Modifier and TypeMethod and Description
public LeastSquaresProblem.Evaluation

Returns:

the model's value and derivative at the given point.
evaluate
(RealVector
the parameter values.
point
)

Evaluate the model at the specified point.

public int

Returns:

the number of scalar observations
getObservationSize
()

Get the number of observations (rows in the Jacobian) in this problem.

public int

Returns:

the number of scalar parameters
getParameterSize
()

Get the number of parameters (columns in the Jacobian) in this problem.

public RealVector

Returns:

the initial guess values.
getStart
()

Gets the initial guess.

Inherited from org.apache.commons.math3.optim.OptimizationProblem:
getConvergenceCheckergetEvaluationCountergetIterationCounter

Method Detail

evaluateback to summary
public LeastSquaresProblem.Evaluation evaluate(RealVector point)

Evaluate the model at the specified point.

Parameters
point:RealVector

the parameter values.

Returns:LeastSquaresProblem.Evaluation

the model's value and derivative at the given point.

Exceptions
TooManyEvaluationsException:
if the maximal number of evaluations (of the model vector function) is exceeded.
getObservationSizeback to summary
public int getObservationSize()

Get the number of observations (rows in the Jacobian) in this problem.

Returns:int

the number of scalar observations

getParameterSizeback to summary
public int getParameterSize()

Get the number of parameters (columns in the Jacobian) in this problem.

Returns:int

the number of scalar parameters

getStartback to summary
public RealVector getStart()

Gets the initial guess.

Returns:RealVector

the initial guess values.

org.apache.commons.math3.fitting.leastsquares back to summary

public Interface LeastSquaresProblem.Evaluation

Known Direct Subinterfaces
org.apache.commons.math3.fitting.leastsquares.LeastSquaresOptimizer.Optimum
Known Direct Implementers
org.apache.commons.math3.fitting.leastsquares.AbstractEvaluation

An evaluation of a LeastSquaresProblem at a particular point. This class also computes several quantities derived from the value and its Jacobian.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

the cost.
getCost
()

Get the cost.

public RealMatrix

Returns:

the covariance matrix.
getCovariances
(double
Singularity threshold.
threshold
)

Get the covariance matrix of the optimized parameters.

public RealMatrix

Returns:

the weighted Jacobian: W1/2 J.
getJacobian
()

Get the weighted Jacobian matrix.

public RealVector

Returns:

the point provided to evaluate(RealVector).
getPoint
()

Get the abscissa (independent variables) of this evaluation.

public RealVector

Returns:

the weighted residuals: W1/2 K.
getResiduals
()

Get the weighted residuals.

public double

Returns:

the cost.
getRMS
()

Get the normalized cost.

public RealVector

Returns:

an estimate of the standard deviation of the optimized parameters
getSigma
(double
Singularity threshold (see computeCovariances).
covarianceSingularityThreshold
)

Get an estimate of the standard deviation of the parameters.

Method Detail

getCostback to summary
public double getCost()

Get the cost.

Returns:double

the cost.

See Also
getResiduals()
getCovariancesback to summary
public RealMatrix getCovariances(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
threshold:double

Singularity threshold.

Returns:RealMatrix

the covariance matrix.

Exceptions
SingularMatrixException:
if the covariance matrix cannot be computed (singular problem).
getJacobianback to summary
public RealMatrix getJacobian()

Get the weighted Jacobian matrix.

Returns:RealMatrix

the weighted Jacobian: W1/2 J.

Exceptions
DimensionMismatchException:
if the Jacobian dimension does not match problem dimension.
getPointback to summary
public RealVector getPoint()

Get the abscissa (independent variables) of this evaluation.

Returns:RealVector

the point provided to evaluate(RealVector).

getResidualsback to summary
public RealVector getResiduals()

Get the weighted 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. The raw residuals are then multiplied by the square root of the weight matrix.

Returns:RealVector

the weighted residuals: W1/2 K.

Exceptions
DimensionMismatchException:
if the residuals have the wrong length.
getRMSback to summary
public double getRMS()

Get the normalized cost. It is the square-root of the sum of squared of the residuals, divided by the number of measurements.

Returns:double

the cost.

getSigmaback to summary
public RealVector getSigma(double covarianceSingularityThreshold)

Get 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
covarianceSingularityThreshold:double

Singularity threshold (see computeCovariances).

Returns:RealVector

an estimate of the standard deviation of the optimized parameters

Exceptions
SingularMatrixException:
if the covariance matrix cannot be computed.