org.apache.commons.math3.optimization.general
Class AbstractLeastSquaresOptimizer
- java.lang.Object
-
- org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateVectorOptimizer<DifferentiableMultivariateVectorFunction>
-
- org.apache.commons.math3.optimization.general.AbstractLeastSquaresOptimizer
-
- All Implemented Interfaces:
- BaseMultivariateVectorOptimizer<DifferentiableMultivariateVectorFunction>, BaseOptimizer<PointVectorValuePair>, DifferentiableMultivariateVectorOptimizer
- Direct Known Subclasses:
- GaussNewtonOptimizer, LevenbergMarquardtOptimizer
Deprecated.As of 3.1 (to be removed in 4.0).
@Deprecated public abstract class AbstractLeastSquaresOptimizer extends BaseAbstractMultivariateVectorOptimizer<DifferentiableMultivariateVectorFunction> implements DifferentiableMultivariateVectorOptimizer
Base class for implementing least squares optimizers. It handles the boilerplate methods associated to thresholds settings, Jacobian and error estimation.
This class constructs the Jacobian matrix of the function argument in methodoptimizeand assumes that the rows of that matrix iterate on the model functions while the columns iterate on the parameters; thus, the numbers of rows is equal to the dimension of theTargetwhile the number of columns is equal to the dimension of theInitialGuess.- Since:
- 1.2
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description double[][]computeCovariances(double[] params, double threshold)Deprecated.Get the covariance matrix of the optimized parameters.double[]computeSigma(double[] params, double covarianceSingularityThreshold)Deprecated.Computes an estimate of the standard deviation of the parameters.doublegetChiSquare()Deprecated.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.double[][]getCovariances()Deprecated.As of 3.1. Please usecomputeCovariances(double[],double)instead.double[][]getCovariances(double threshold)Deprecated.As of 3.1. Please usecomputeCovariances(double[],double)instead.intgetJacobianEvaluations()Deprecated.doublegetRMS()Deprecated.Get the Root Mean Square value.RealMatrixgetWeightSquareRoot()Deprecated.Gets the square-root of the weight matrix.double[]guessParametersErrors()Deprecated.as of version 3.1,computeSigma(double[],double)should be used instead. It should be emphasized thatguessParametersErrorsandcomputeSigmaare not strictly equivalent.PointVectorValuePairoptimize(int maxEval, DifferentiableMultivariateVectorFunction f, double[] target, double[] weights, double[] startPoint)Deprecated.As of 3.1. Please useoptimize(int,MultivariateDifferentiableVectorFunction,OptimizationData...)instead.PointVectorValuePairoptimize(int maxEval, MultivariateDifferentiableVectorFunction f, double[] target, double[] weights, double[] startPoint)Deprecated.As of 3.1. Please useoptimize(int,MultivariateDifferentiableVectorFunction,OptimizationData...)instead.-
Methods inherited from class org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateVectorOptimizer
getConvergenceChecker, getEvaluations, getMaxEvaluations, getStartPoint, getTarget, getWeight
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math3.optimization.BaseOptimizer
getConvergenceChecker, getEvaluations, getMaxEvaluations
-
-
-
-
Method Detail
-
getJacobianEvaluations
public int getJacobianEvaluations()
Deprecated.- Returns:
- the number of evaluations of the Jacobian function.
-
getRMS
public double getRMS()
Deprecated.Get the Root Mean Square value. Get the Root Mean Square value, i.e. 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:
- RMS value
-
getChiSquare
public double getChiSquare()
Deprecated.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:
- chi-square value
-
getWeightSquareRoot
public RealMatrix getWeightSquareRoot()
Deprecated.Gets the square-root of the weight matrix.- Returns:
- the square-root of the weight matrix.
- Since:
- 3.1
-
getCovariances
@Deprecated public double[][] getCovariances()
Deprecated. As of 3.1. Please usecomputeCovariances(double[],double)instead.Get the covariance matrix of the optimized parameters.- Returns:
- the covariance matrix.
- Throws:
SingularMatrixException- if the covariance matrix cannot be computed (singular problem).- See Also:
getCovariances(double)
-
getCovariances
@Deprecated public double[][] getCovariances(double threshold)
Deprecated. As of 3.1. Please usecomputeCovariances(double[],double)instead.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.- Parameters:
threshold- Singularity threshold.- Returns:
- the covariance matrix.
- Throws:
SingularMatrixException- if the covariance matrix cannot be computed (singular problem).
-
computeCovariances
public double[][] computeCovariances(double[] params, double threshold)Deprecated.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.- Parameters:
params- Model parameters.threshold- Singularity threshold.- Returns:
- the covariance matrix.
- Throws:
SingularMatrixException- if the covariance matrix cannot be computed (singular problem).- Since:
- 3.1
-
guessParametersErrors
@Deprecated public double[] guessParametersErrors()
Deprecated. as of version 3.1,computeSigma(double[],double)should be used instead. It should be emphasized thatguessParametersErrorsandcomputeSigmaare not strictly equivalent.Returns an estimate of the standard deviation of each parameter. The returned values are the so-called (asymptotic) standard errors on the parameters, defined as
sd(a[i]) = sqrt(S / (n - m) * C[i][i]), wherea[i]is the optimized value of thei-th parameter,Sis the minimized value of the sum of squares objective function (as returned bygetChiSquare()),nis the number of observations,mis the number of parameters andCis the covariance matrix.See also Wikipedia, or MathWorld, equations (34) and (35) for a particular case.
- Returns:
- an estimate of the standard deviation of the optimized parameters
- Throws:
SingularMatrixException- if the covariance matrix cannot be computed.NumberIsTooSmallException- if the number of degrees of freedom is not positive, i.e. the number of measurements is less or equal to the number of parameters.
-
computeSigma
public double[] computeSigma(double[] params, double covarianceSingularityThreshold)Deprecated.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]), wherea[i]is the optimized value of thei-th parameter, andCis the covariance matrix.- Parameters:
params- Model parameters.covarianceSingularityThreshold- Singularity threshold (seecomputeCovariances).- Returns:
- an estimate of the standard deviation of the optimized parameters
- Throws:
SingularMatrixException- if the covariance matrix cannot be computed.- Since:
- 3.1
-
optimize
@Deprecated public PointVectorValuePair optimize(int maxEval, DifferentiableMultivariateVectorFunction f, double[] target, double[] weights, double[] startPoint)
Deprecated. As of 3.1. Please useoptimize(int,MultivariateDifferentiableVectorFunction,OptimizationData...)instead.Optimize an objective function. Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is∑weighti(objectivei - targeti)2- Specified by:
optimizein interfaceBaseMultivariateVectorOptimizer<DifferentiableMultivariateVectorFunction>- Overrides:
optimizein classBaseAbstractMultivariateVectorOptimizer<DifferentiableMultivariateVectorFunction>- Parameters:
maxEval- Maximum number of function evaluations.f- Objective function.target- Target value for the objective functions at optimum.weights- Weights for the least squares cost computation.startPoint- Start point for optimization.- Returns:
- the point/value pair giving the optimal value for objective function.
-
optimize
@Deprecated public PointVectorValuePair optimize(int maxEval, MultivariateDifferentiableVectorFunction f, double[] target, double[] weights, double[] startPoint)
Deprecated. As of 3.1. Please useoptimize(int,MultivariateDifferentiableVectorFunction,OptimizationData...)instead.Optimize an objective function. Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is∑weighti(objectivei - targeti)2- Parameters:
f- Objective function.target- Target value for the objective functions at optimum.weights- Weights for the least squares cost computation.startPoint- Start point for optimization.maxEval- Maximum number of function evaluations.- Returns:
- the point/value pair giving the optimal value for objective function.
- Throws:
DimensionMismatchException- if the start point dimension is wrong.TooManyEvaluationsException- if the maximal number of evaluations is exceeded.NullArgumentException- if any argument isnull.
-
-
DMelt 3.0 © DataMelt by jWork.ORG