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 intnumber of evaluations to compute this optimumprivate final intnumber of iterations to compute this optimumprivate final LeastSquaresProblem.Evaluationabscissa 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 TypeMethodDescriptiondoublegetCost()Get the cost.getCovariances(double threshold) Get the covariance matrix of the optimized parameters.intGet the number of times the model was evaluated in order to produce this optimum.intGet 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.doublegetRMS()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:
getEvaluationsin 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 oneevaluationper iterations.- Specified by:
getIterationsin interfaceLeastSquaresOptimizer.Optimum- Returns:
- the number of iterations
-
getCovariances
Get the covariance matrix of the optimized parameters.
Note that this operation involves the inversion of theJTJmatrix, whereJis the Jacobian matrix. Thethresholdparameter 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:
getCovariancesin 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, andCis the covariance matrix.- Specified by:
getSigmain 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:
getRMSin interfaceLeastSquaresProblem.Evaluation- Returns:
- the cost.
-
getJacobian
Get the weighted Jacobian matrix.- Specified by:
getJacobianin interfaceLeastSquaresProblem.Evaluation- Returns:
- the weighted Jacobian: W1/2 J.
-
getCost
public double getCost()Get the cost.- Specified by:
getCostin 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:
getResidualsin interfaceLeastSquaresProblem.Evaluation- Returns:
- the weighted residuals: W1/2 K.
-
getPoint
Get the abscissa (independent variables) of this evaluation.- Specified by:
getPointin interfaceLeastSquaresProblem.Evaluation- Returns:
- the point provided to
LeastSquaresProblem.evaluate(RealVector).
-