use of org.apache.commons.math3.fitting.leastsquares.GaussNewtonOptimizer in project imagingbook-common by imagingbook.
the class NonlinearLeastSquares method solveGaussNewton.
/**
* Solves the nonlinear least-squares problem defined by the arguments
* using Gauss-Newton optimization.
*
* @param V the "value" function, V(p) must return a vector for the current parameters p
* @param J the "Jacobian" function, J(p) must return a matrix for the current parameters p
* @param z the vector of observed ("target") values
* @param p0 initial parameter vector
* @return the vector of optimal parameters
*/
public static RealVector solveGaussNewton(MultivariateVectorFunction V, MultivariateMatrixFunction J, RealVector z, RealVector p0) {
LeastSquaresProblem problem = makeProblem(V, J, z, p0);
LeastSquaresOptimizer optimizer = new GaussNewtonOptimizer();
Optimum solution = optimizer.optimize(problem);
// System.out.println("iterations = " + solution.getIterations());
return solution.getPoint();
}
Aggregations