Class OptimumImpl
- java.lang.Object
-
- org.apache.commons.math3.fitting.leastsquares.OptimumImpl
-
- All Implemented Interfaces:
LeastSquaresOptimizer.Optimum
,LeastSquaresProblem.Evaluation
class OptimumImpl extends java.lang.Object implements LeastSquaresOptimizer.Optimum
A pedantic implementation ofLeastSquaresOptimizer.Optimum
.- Since:
- 3.3
-
-
Field Summary
Fields Modifier and Type Field Description private int
evaluations
number of evaluations to compute this optimumprivate int
iterations
number of iterations to compute this optimumprivate LeastSquaresProblem.Evaluation
value
abscissa and ordinate
-
Constructor Summary
Constructors Constructor Description OptimumImpl(LeastSquaresProblem.Evaluation value, int evaluations, int iterations)
Construct an optimum from an evaluation and the values of the counters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getCost()
Get the cost.RealMatrix
getCovariances(double threshold)
Get the covariance matrix of the optimized parameters.int
getEvaluations()
Get the number of times the model was evaluated in order to produce this optimum.int
getIterations()
Get the number of times the algorithm iterated in order to produce this optimum.RealMatrix
getJacobian()
Get the weighted Jacobian matrix.RealVector
getPoint()
Get the abscissa (independent variables) of this evaluation.RealVector
getResiduals()
Get the weighted residuals.double
getRMS()
Get the normalized cost.RealVector
getSigma(double covarianceSingularityThreshold)
Get an estimate of the standard deviation of the parameters.
-
-
-
Field Detail
-
value
private final LeastSquaresProblem.Evaluation value
abscissa and ordinate
-
evaluations
private final int evaluations
number of evaluations to compute this optimum
-
iterations
private final int iterations
number of iterations to compute this optimum
-
-
Constructor Detail
-
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 Detail
-
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
public RealMatrix getCovariances(double threshold)
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
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])
, 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
public RealMatrix 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:
LeastSquaresProblem.Evaluation.getResiduals()
-
getResiduals
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.- Specified by:
getResiduals
in interfaceLeastSquaresProblem.Evaluation
- Returns:
- the weighted residuals: W1/2 K.
-
getPoint
public RealVector getPoint()
Get the abscissa (independent variables) of this evaluation.- Specified by:
getPoint
in interfaceLeastSquaresProblem.Evaluation
- Returns:
- the point provided to
LeastSquaresProblem.evaluate(RealVector)
.
-
-