Class LeastSquaresFactory
- java.lang.Object
-
- org.apache.commons.math4.legacy.fitting.leastsquares.LeastSquaresFactory
-
public final class LeastSquaresFactory extends Object
A Factory for creatingLeastSquaresProblems.- Since:
- 3.3
-
-
Method Summary
-
-
-
Method Detail
-
create
public static LeastSquaresProblem create(MultivariateJacobianFunction model, RealVector observed, RealVector start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations, boolean lazyEvaluation, ParameterValidator paramValidator)
Create aLeastSquaresProblemfrom the given elements.- Parameters:
model- the model function. Produces the computed values.observed- the observed (target) valuesstart- the initial guess.weight- the weight matrixchecker- convergence checkermaxEvaluations- the maximum number of times to evaluate the modelmaxIterations- the maximum number to times to iterate in the algorithmlazyEvaluation- Whether the call toLeastSquaresProblem.evaluate(RealVector)will defer the evaluation until access to the value is requested.paramValidator- Model parameters validator.- Returns:
- the specified General Least Squares problem.
- Since:
- 3.4
-
create
public static LeastSquaresProblem create(MultivariateJacobianFunction model, RealVector observed, RealVector start, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations)
Create aLeastSquaresProblemfrom the given elements. There will be no weights applied (unit weights).- Parameters:
model- the model function. Produces the computed values.observed- the observed (target) valuesstart- the initial guess.checker- convergence checkermaxEvaluations- the maximum number of times to evaluate the modelmaxIterations- the maximum number to times to iterate in the algorithm- Returns:
- the specified General Least Squares problem.
-
create
public static LeastSquaresProblem create(MultivariateJacobianFunction model, RealVector observed, RealVector start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations)
Create aLeastSquaresProblemfrom the given elements.- Parameters:
model- the model function. Produces the computed values.observed- the observed (target) valuesstart- the initial guess.weight- the weight matrixchecker- convergence checkermaxEvaluations- the maximum number of times to evaluate the modelmaxIterations- the maximum number to times to iterate in the algorithm- Returns:
- the specified General Least Squares problem.
-
create
public static LeastSquaresProblem create(MultivariateVectorFunction model, MultivariateMatrixFunction jacobian, double[] observed, double[] start, RealMatrix weight, ConvergenceChecker<LeastSquaresProblem.Evaluation> checker, int maxEvaluations, int maxIterations)
Create aLeastSquaresProblemfrom the given elements.This factory method is provided for continuity with previous interfaces. Newer applications should use
create(MultivariateJacobianFunction, RealVector, RealVector, ConvergenceChecker, int, int), orcreate(MultivariateJacobianFunction, RealVector, RealVector, RealMatrix, ConvergenceChecker, int, int).- Parameters:
model- the model function. Produces the computed values.jacobian- the jacobian of the model with respect to the parametersobserved- the observed (target) valuesstart- the initial guess.weight- the weight matrixchecker- convergence checkermaxEvaluations- the maximum number of times to evaluate the modelmaxIterations- the maximum number to times to iterate in the algorithm- Returns:
- the specified General Least Squares problem.
-
weightMatrix
public static LeastSquaresProblem weightMatrix(LeastSquaresProblem problem, RealMatrix weights)
Apply a dense weight matrix to theLeastSquaresProblem.- Parameters:
problem- the unweighted problemweights- the matrix of weights- Returns:
- a new
LeastSquaresProblemwith the weights applied. The originalproblemis not modified.
-
weightDiagonal
public static LeastSquaresProblem weightDiagonal(LeastSquaresProblem problem, RealVector weights)
Apply a diagonal weight matrix to theLeastSquaresProblem.- Parameters:
problem- the unweighted problemweights- the diagonal of the weight matrix- Returns:
- a new
LeastSquaresProblemwith the weights applied. The originalproblemis not modified.
-
countEvaluations
public static LeastSquaresProblem countEvaluations(LeastSquaresProblem problem, IntegerSequence.Incrementor counter)
Count the evaluations of a particular problem. Thecounterwill be incremented every timeLeastSquaresProblem.evaluate(RealVector)is called on the returned problem.- Parameters:
problem- the problem to track.counter- the counter to increment.- Returns:
- a least squares problem that tracks evaluations
-
evaluationChecker
public static ConvergenceChecker<LeastSquaresProblem.Evaluation> evaluationChecker(ConvergenceChecker<PointVectorValuePair> checker)
View a convergence checker specified for aPointVectorValuePairas one specified for anLeastSquaresProblem.Evaluation.- Parameters:
checker- the convergence checker to adapt.- Returns:
- a convergence checker that delegates to
checker.
-
model
public static MultivariateJacobianFunction model(MultivariateVectorFunction value, MultivariateMatrixFunction jacobian)
Combine aMultivariateVectorFunctionwith aMultivariateMatrixFunctionto produce aMultivariateJacobianFunction.- Parameters:
value- the vector value functionjacobian- the Jacobian function- Returns:
- a function that computes both at the same time
-
-