Class NonLinearLeastSquare
- java.lang.Object
-
- com.opengamma.strata.math.impl.statistics.leastsquare.NonLinearLeastSquare
-
public class NonLinearLeastSquare extends Object
Non linear least square calculator.
-
-
Constructor Summary
Constructors Constructor Description NonLinearLeastSquare()
NonLinearLeastSquare(Decomposition<?> decomposition, MatrixAlgebra algebra, double eps)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleMatrix
calInverseJacobian(DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray originalSolution)
the inverse-Jacobian where the i-j entry is the sensitivity of the ith (fitted) parameter (a_i) to the jth data point (y_j).LeastSquareResults
solve(DoubleArray x, DoubleArray y, double sigma, ParameterizedFunction<Double,DoubleArray,Double> func, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity is not available but a measurement error is.LeastSquareResults
solve(DoubleArray x, DoubleArray y, double sigma, ParameterizedFunction<Double,DoubleArray,Double> func, ParameterizedFunction<Double,DoubleArray,DoubleArray> grad, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity and a single measurement error are available.LeastSquareResults
solve(DoubleArray x, DoubleArray y, DoubleArray sigma, ParameterizedFunction<Double,DoubleArray,Double> func, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity is not available but an array of measurements errors is.LeastSquareResults
solve(DoubleArray x, DoubleArray y, DoubleArray sigma, ParameterizedFunction<Double,DoubleArray,Double> func, ParameterizedFunction<Double,DoubleArray,DoubleArray> grad, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity and measurement errors are available.LeastSquareResults
solve(DoubleArray x, DoubleArray y, ParameterizedFunction<Double,DoubleArray,Double> func, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity is not available.LeastSquareResults
solve(DoubleArray x, DoubleArray y, ParameterizedFunction<Double,DoubleArray,Double> func, ParameterizedFunction<Double,DoubleArray,DoubleArray> grad, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity.LeastSquareResults
solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, DoubleArray startPos)
Use this when the model is given as a function of its parameters only (i.e.LeastSquareResults
solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, DoubleArray startPos, DoubleArray maxJumps)
Use this when the model is given as a function of its parameters only (i.e.LeastSquareResults
solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray startPos)
Use this when the model is given as a function of its parameters only (i.e.LeastSquareResults
solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray startPos, DoubleArray maxJumps)
Use this when the model is given as a function of its parameters only (i.e.LeastSquareResults
solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray startPos, Function<DoubleArray,Boolean> constraints, DoubleArray maxJumps)
Use this when the model is given as a function of its parameters only (i.e.LeastSquareResults
solve(DoubleArray observedValues, Function<DoubleArray,DoubleArray> func, DoubleArray startPos)
Use this when the model is given as a function of its parameters only (i.e.
-
-
-
Constructor Detail
-
NonLinearLeastSquare
public NonLinearLeastSquare()
-
NonLinearLeastSquare
public NonLinearLeastSquare(Decomposition<?> decomposition, MatrixAlgebra algebra, double eps)
-
-
Method Detail
-
solve
public LeastSquareResults solve(DoubleArray x, DoubleArray y, ParameterizedFunction<Double,DoubleArray,Double> func, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity is not available.- Parameters:
x
- Set of measurement pointsy
- Set of measurement valuesfunc
- The model in ParameterizedFunction form (i.e. takes measurement points and a set of parameters and returns a model value)startPos
- Initial value of the parameters- Returns:
- A LeastSquareResults object
-
solve
public LeastSquareResults solve(DoubleArray x, DoubleArray y, double sigma, ParameterizedFunction<Double,DoubleArray,Double> func, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity is not available but a measurement error is.- Parameters:
x
- Set of measurement pointsy
- Set of measurement valuessigma
- y Set of measurement errorsfunc
- The model in ParameterizedFunction form (i.e. takes measurement points and a set of parameters and returns a model value)startPos
- Initial value of the parameters- Returns:
- A LeastSquareResults object
-
solve
public LeastSquareResults solve(DoubleArray x, DoubleArray y, DoubleArray sigma, ParameterizedFunction<Double,DoubleArray,Double> func, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity is not available but an array of measurements errors is.- Parameters:
x
- Set of measurement pointsy
- Set of measurement valuessigma
- Set of measurement errorsfunc
- The model in ParameterizedFunction form (i.e. takes measurement points and a set of parameters and returns a model value)startPos
- Initial value of the parameters- Returns:
- A LeastSquareResults object
-
solve
public LeastSquareResults solve(DoubleArray x, DoubleArray y, ParameterizedFunction<Double,DoubleArray,Double> func, ParameterizedFunction<Double,DoubleArray,DoubleArray> grad, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity.- Parameters:
x
- Set of measurement pointsy
- Set of measurement valuesfunc
- The model in ParameterizedFunction form (i.e. takes a measurement points and a set of parameters and returns a model value)grad
- The model parameter sensitivities in ParameterizedFunction form (i.e. takes a measurement points and a set of parameters and returns a model parameter sensitivities)startPos
- Initial value of the parameters- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray x, DoubleArray y, double sigma, ParameterizedFunction<Double,DoubleArray,Double> func, ParameterizedFunction<Double,DoubleArray,DoubleArray> grad, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity and a single measurement error are available.- Parameters:
x
- Set of measurement pointsy
- Set of measurement valuessigma
- Measurement errorsfunc
- The model in ParameterizedFunction form (i.e. takes a measurement points and a set of parameters and returns a model value)grad
- The model parameter sensitivities in ParameterizedFunction form (i.e. takes a measurement points and a set of parameters and returns a model parameter sensitivities)startPos
- Initial value of the parameters- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray x, DoubleArray y, DoubleArray sigma, ParameterizedFunction<Double,DoubleArray,Double> func, ParameterizedFunction<Double,DoubleArray,DoubleArray> grad, DoubleArray startPos)
Use this when the model is in the ParameterizedFunction form and analytic parameter sensitivity and measurement errors are available.- Parameters:
x
- Set of measurement pointsy
- Set of measurement valuessigma
- Set of measurement errorsfunc
- The model in ParameterizedFunction form (i.e. takes a measurement points and a set of parameters and returns a model value)grad
- The model parameter sensitivities in ParameterizedFunction form (i.e. takes a measurement points and a set of parameters and returns a model parameter sensitivities)startPos
- Initial value of the parameters- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray observedValues, Function<DoubleArray,DoubleArray> func, DoubleArray startPos)
Use this when the model is given as a function of its parameters only (i.e. a function that takes a set of parameters and return a set of model values, so the measurement points are already known to the function), and analytic parameter sensitivity is not available- Parameters:
observedValues
- Set of measurement valuesfunc
- The model as a function of its parameters onlystartPos
- Initial value of the parameters- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, DoubleArray startPos)
Use this when the model is given as a function of its parameters only (i.e. a function that takes a set of parameters and return a set of model values, so the measurement points are already known to the function), and analytic parameter sensitivity is not available- Parameters:
observedValues
- Set of measurement valuessigma
- Set of measurement errorsfunc
- The model as a function of its parameters onlystartPos
- Initial value of the parameters- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, DoubleArray startPos, DoubleArray maxJumps)
Use this when the model is given as a function of its parameters only (i.e. a function that takes a set of parameters and return a set of model values, so the measurement points are already known to the function), and analytic parameter sensitivity is not available- Parameters:
observedValues
- Set of measurement valuessigma
- Set of measurement errorsfunc
- The model as a function of its parameters onlystartPos
- Initial value of the parametersmaxJumps
- A vector containing the maximum absolute allowed step in a particular direction in each iteration. Can be null, in which case no constant on the step size is applied.- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray startPos)
Use this when the model is given as a function of its parameters only (i.e. a function that takes a set of parameters and return a set of model values, so the measurement points are already known to the function), and analytic parameter sensitivity is available- Parameters:
observedValues
- Set of measurement valuessigma
- Set of measurement errorsfunc
- The model as a function of its parameters onlyjac
- The model sensitivity to its parameters (i.e. the Jacobian matrix) as a function of its parameters onlystartPos
- Initial value of the parameters- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray startPos, DoubleArray maxJumps)
Use this when the model is given as a function of its parameters only (i.e. a function that takes a set of parameters and return a set of model values, so the measurement points are already known to the function), and analytic parameter sensitivity is available- Parameters:
observedValues
- Set of measurement valuessigma
- Set of measurement errorsfunc
- The model as a function of its parameters onlyjac
- The model sensitivity to its parameters (i.e. the Jacobian matrix) as a function of its parameters onlystartPos
- Initial value of the parametersmaxJumps
- A vector containing the maximum absolute allowed step in a particular direction in each iteration. Can be null, in which case on constant on the step size is applied.- Returns:
- value of the fitted parameters
-
solve
public LeastSquareResults solve(DoubleArray observedValues, DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray startPos, Function<DoubleArray,Boolean> constraints, DoubleArray maxJumps)
Use this when the model is given as a function of its parameters only (i.e. a function that takes a set of parameters and return a set of model values, so the measurement points are already known to the function), and analytic parameter sensitivity is available- Parameters:
observedValues
- Set of measurement valuessigma
- Set of measurement errorsfunc
- The model as a function of its parameters onlyjac
- The model sensitivity to its parameters (i.e. the Jacobian matrix) as a function of its parameters onlystartPos
- Initial value of the parametersconstraints
- A function that returns true if the trial point is within the constraints of the modelmaxJumps
- A vector containing the maximum absolute allowed step in a particular direction in each iteration. Can be null, in which case on constant on the step size is applied.- Returns:
- value of the fitted parameters
-
calInverseJacobian
public DoubleMatrix calInverseJacobian(DoubleArray sigma, Function<DoubleArray,DoubleArray> func, Function<DoubleArray,DoubleMatrix> jac, DoubleArray originalSolution)
the inverse-Jacobian where the i-j entry is the sensitivity of the ith (fitted) parameter (a_i) to the jth data point (y_j).- Parameters:
sigma
- Set of measurement errorsfunc
- The model as a function of its parameters onlyjac
- The model sensitivity to its parameters (i.e. the Jacobian matrix) as a function of its parameters onlyoriginalSolution
- The value of the parameters at a converged solution- Returns:
- inverse-Jacobian
-
-