Class OptimumImpl
java.lang.Object
org.apache.commons.math3.fitting.leastsquares.OptimumImpl
- All Implemented Interfaces:
LeastSquaresOptimizer.Optimum
,LeastSquaresProblem.Evaluation
A pedantic implementation of
LeastSquaresOptimizer.Optimum
.- Since:
- 3.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
number of evaluations to compute this optimumprivate final int
number of iterations to compute this optimumprivate final LeastSquaresProblem.Evaluation
abscissa and ordinate -
Constructor Summary
ConstructorsConstructorDescriptionOptimumImpl
(LeastSquaresProblem.Evaluation value, int evaluations, int iterations) Construct an optimum from an evaluation and the values of the counters. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getCost()
Get the cost.getCovariances
(double threshold) Get the covariance matrix of the optimized parameters.int
Get the number of times the model was evaluated in order to produce this optimum.int
Get the number of times the algorithm iterated in order to produce this optimum.Get the weighted Jacobian matrix.getPoint()
Get the abscissa (independent variables) of this evaluation.Get the weighted residuals.double
getRMS()
Get the normalized cost.getSigma
(double covarianceSingularityThreshold) Get an estimate of the standard deviation of the parameters.
-
Field Details
-
value
abscissa and ordinate -
evaluations
private final int evaluationsnumber of evaluations to compute this optimum -
iterations
private final int iterationsnumber of iterations to compute this optimum
-
-
Constructor Details
-
OptimumImpl
OptimumImpl(LeastSquaresProblem.Evaluation value, int evaluations, int iterations) Construct an optimum from an evaluation and the values of the counters.- Parameters:
value
- the function valueevaluations
- number of times the function was evaluatediterations
- number of iterations of the algorithm
-
-
Method Details
-
getEvaluations
public int getEvaluations()Get the number of times the model was evaluated in order to produce this optimum.- Specified by:
getEvaluations
in interfaceLeastSquaresOptimizer.Optimum
- Returns:
- the number of model (objective) function evaluations
-
getIterations
public int getIterations()Get the number of times the algorithm iterated in order to produce this optimum. In general least squares it is common to have oneevaluation
per iterations.- Specified by:
getIterations
in interfaceLeastSquaresOptimizer.Optimum
- Returns:
- the number of iterations
-
getCovariances
Get the covariance matrix of the optimized parameters.
Note that this operation involves the inversion of theJTJ
matrix, whereJ
is the Jacobian matrix. Thethreshold
parameter is a way for the caller to specify that the result of this computation should be considered meaningless, and thus trigger an exception.- Specified by:
getCovariances
in interfaceLeastSquaresProblem.Evaluation
- Parameters:
threshold
- Singularity threshold.- Returns:
- the covariance matrix.
-
getSigma
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])
, wherea[i]
is the optimized value of thei
-th parameter, andC
is the covariance matrix.- Specified by:
getSigma
in interfaceLeastSquaresProblem.Evaluation
- Parameters:
covarianceSingularityThreshold
- Singularity threshold (seecomputeCovariances
).- Returns:
- an estimate of the standard deviation of the optimized parameters
-
getRMS
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.- Specified by:
getRMS
in interfaceLeastSquaresProblem.Evaluation
- Returns:
- the cost.
-
getJacobian
Get the weighted Jacobian matrix.- Specified by:
getJacobian
in interfaceLeastSquaresProblem.Evaluation
- Returns:
- the weighted Jacobian: W1/2 J.
-
getCost
public double getCost()Get the cost.- Specified by:
getCost
in interfaceLeastSquaresProblem.Evaluation
- Returns:
- the cost.
- See Also:
-
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.- Specified by:
getResiduals
in interfaceLeastSquaresProblem.Evaluation
- Returns:
- the weighted residuals: W1/2 K.
-
getPoint
Get the abscissa (independent variables) of this evaluation.- Specified by:
getPoint
in interfaceLeastSquaresProblem.Evaluation
- Returns:
- the point provided to
LeastSquaresProblem.evaluate(RealVector)
.
-