org.apache.commons.math3.optim.nonlinear.vector.ModelFunctionJacobian Java Examples
The following examples show how to use
org.apache.commons.math3.optim.nonlinear.vector.ModelFunctionJacobian.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LevenbergMarquardtOptimizerTest.java From astor with GNU General Public License v2.0 | 6 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { double[][] jacobian = new double[time.size()][5]; for (int i = 0; i < jacobian.length; ++i) { final double t = time.get(i); jacobian[i][0] = 1; final double p3 = params[3]; final double p4 = params[4]; final double tOp3 = t / p3; final double tOp4 = t / p4; jacobian[i][1] = FastMath.exp(-tOp3); jacobian[i][2] = FastMath.exp(-tOp4); jacobian[i][3] = params[1] * FastMath.exp(-tOp3) * tOp3 / p3; jacobian[i][4] = params[2] * FastMath.exp(-tOp4) * tOp4 / p4; } return jacobian; } }); }
Example #2
Source File: LSQFitter.java From thunderstorm with GNU General Public License v3.0 | 6 votes |
protected Molecule fit(ILsqFunctions functions) { // init double[] weights = functions.calcWeights(useWeighting); double[] observations = functions.getObservations(); // fit LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer( new SimplePointChecker<PointVectorValuePair>(10e-10, 10e-10, maxIter)); PointVectorValuePair pv; pv = optimizer.optimize( MaxEval.unlimited(), new MaxIter(MAX_ITERATIONS + 1), new ModelFunction(functions.getValueFunction()), new ModelFunctionJacobian(functions.getJacobianFunction()), new Target(observations), new InitialGuess(psfModel.transformParametersInverse(functions.getInitialParams())), new Weight(weights)); // estimate background and return an instance of the `Molecule` fittedParameters = pv.getPointRef(); if (bkgStdColumn >= 0) { fittedParameters[bkgStdColumn] = VectorMath.stddev(sub(observations, functions.getValueFunction().value(fittedParameters))); } return psfModel.newInstanceFromParams(psfModel.transformParameters(fittedParameters), functions.getImageUnits(), true); }
Example #3
Source File: LevenbergMarquardtOptimizerTest.java From astor with GNU General Public License v2.0 | 6 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { double[][] jacobian = new double[time.size()][5]; for (int i = 0; i < jacobian.length; ++i) { final double t = time.get(i); jacobian[i][0] = 1; final double p3 = params[3]; final double p4 = params[4]; final double tOp3 = t / p3; final double tOp4 = t / p4; jacobian[i][1] = Math.exp(-tOp3); jacobian[i][2] = Math.exp(-tOp4); jacobian[i][3] = params[1] * Math.exp(-tOp3) * tOp3 / p3; jacobian[i][4] = params[2] * Math.exp(-tOp4) * tOp4 / p4; } return jacobian; } }); }
Example #4
Source File: LevenbergMarquardtOptimizerTest.java From astor with GNU General Public License v2.0 | 6 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { double[][] jacobian = new double[time.size()][5]; for (int i = 0; i < jacobian.length; ++i) { final double t = time.get(i); jacobian[i][0] = 1; final double p3 = params[3]; final double p4 = params[4]; final double tOp3 = t / p3; final double tOp4 = t / p4; jacobian[i][1] = FastMath.exp(-tOp3); jacobian[i][2] = FastMath.exp(-tOp4); jacobian[i][3] = params[1] * FastMath.exp(-tOp3) * tOp3 / p3; jacobian[i][4] = params[2] * FastMath.exp(-tOp4) * tOp4 / p4; } return jacobian; } }); }
Example #5
Source File: LevenbergMarquardtOptimizerTest.java From astor with GNU General Public License v2.0 | 6 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { double[][] jacobian = new double[time.size()][5]; for (int i = 0; i < jacobian.length; ++i) { final double t = time.get(i); jacobian[i][0] = 1; final double p3 = params[3]; final double p4 = params[4]; final double tOp3 = t / p3; final double tOp4 = t / p4; jacobian[i][1] = Math.exp(-tOp3); jacobian[i][2] = Math.exp(-tOp4); jacobian[i][3] = params[1] * Math.exp(-tOp3) * tOp3 / p3; jacobian[i][4] = params[2] * Math.exp(-tOp4) * tOp4 / p4; } return jacobian; } }); }
Example #6
Source File: LevenbergMarquardtOptimizerTest.java From astor with GNU General Public License v2.0 | 6 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { double[][] jacobian = new double[time.size()][5]; for (int i = 0; i < jacobian.length; ++i) { final double t = time.get(i); jacobian[i][0] = 1; final double p3 = params[3]; final double p4 = params[4]; final double tOp3 = t / p3; final double tOp4 = t / p4; jacobian[i][1] = Math.exp(-tOp3); jacobian[i][2] = Math.exp(-tOp4); jacobian[i][3] = params[1] * Math.exp(-tOp3) * tOp3 / p3; jacobian[i][4] = params[2] * Math.exp(-tOp4) * tOp4 / p4; } return jacobian; } }); }
Example #7
Source File: CircleProblem.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return jacobian(point); } }); }
Example #8
Source File: CircleProblem.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return jacobian(point); } }); }
Example #9
Source File: StatisticalReferenceDataset.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(final double[] a) throws IllegalArgumentException { final int n = getNumObservations(); final double[][] j = new double[n][]; for (int i = 0; i < n; i++) { j[i] = getModelDerivatives(getX(i), a); } return j; } }); }
Example #10
Source File: CurveFitter.java From astor with GNU General Public License v2.0 | 5 votes |
/** * @return the model function Jacobian. */ public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { final double[][] jacobian = new double[observations.size()][]; int i = 0; for (WeightedObservedPoint observed : observations) { jacobian[i++] = f.gradient(observed.getX(), point); } return jacobian; } }); }
Example #11
Source File: LevenbergMarquardtOptimizerTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { double[][] jacobian = new double[x.size()][3]; for (int i = 0; i < jacobian.length; ++i) { jacobian[i][0] = x.get(i) * x.get(i); jacobian[i][1] = x.get(i); jacobian[i][2] = 1.0; } return jacobian; } }); }
Example #12
Source File: AbstractLeastSquaresOptimizerAbstractTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { return factors.getData(); } }); }
Example #13
Source File: CircleVectorial.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { final int n = points.size(); final Vector2D center = new Vector2D(params[0], params[1]); double dRdX = 0; double dRdY = 0; for (Vector2D pk : points) { double dk = pk.distance(center); dRdX += (center.getX() - pk.getX()) / dk; dRdY += (center.getY() - pk.getY()) / dk; } dRdX /= n; dRdY /= n; // Jacobian of the radius residuals. double[][] jacobian = new double[n][2]; for (int i = 0; i < n; i++) { final Vector2D pi = points.get(i); final double di = pi.distance(center); jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX; jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY; } return jacobian; } }); }
Example #14
Source File: StraightLineProblem.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return jacobian(point); } }); }
Example #15
Source File: MinpackTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return computeJacobian(point); } }); }
Example #16
Source File: CircleVectorial.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { final int n = points.size(); final Vector2D center = new Vector2D(params[0], params[1]); double dRdX = 0; double dRdY = 0; for (Vector2D pk : points) { double dk = pk.distance(center); dRdX += (center.getX() - pk.getX()) / dk; dRdY += (center.getY() - pk.getY()) / dk; } dRdX /= n; dRdY /= n; // Jacobian of the radius residuals. double[][] jacobian = new double[n][2]; for (int i = 0; i < n; i++) { final Vector2D pi = points.get(i); final double di = pi.distance(center); jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX; jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY; } return jacobian; } }); }
Example #17
Source File: StatisticalReferenceDataset.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(final double[] a) throws IllegalArgumentException { final int n = getNumObservations(); final double[][] j = new double[n][]; for (int i = 0; i < n; i++) { j[i] = getModelDerivatives(getX(i), a); } return j; } }); }
Example #18
Source File: CurveFitter.java From astor with GNU General Public License v2.0 | 5 votes |
/** * @return the model function Jacobian. */ public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { final double[][] jacobian = new double[observations.size()][]; int i = 0; for (WeightedObservedPoint observed : observations) { jacobian[i++] = f.gradient(observed.getX(), point); } return jacobian; } }); }
Example #19
Source File: AbstractLeastSquaresOptimizerAbstractTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { return factors.getData(); } }); }
Example #20
Source File: CircleVectorial.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { final int n = points.size(); final Vector2D center = new Vector2D(params[0], params[1]); double dRdX = 0; double dRdY = 0; for (Vector2D pk : points) { double dk = pk.distance(center); dRdX += (center.getX() - pk.getX()) / dk; dRdY += (center.getY() - pk.getY()) / dk; } dRdX /= n; dRdY /= n; // Jacobian of the radius residuals. double[][] jacobian = new double[n][2]; for (int i = 0; i < n; i++) { final Vector2D pi = points.get(i); final double di = pi.distance(center); jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX; jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY; } return jacobian; } }); }
Example #21
Source File: StraightLineProblem.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return jacobian(point); } }); }
Example #22
Source File: MinpackTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return computeJacobian(point); } }); }
Example #23
Source File: CircleProblem.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return jacobian(point); } }); }
Example #24
Source File: StatisticalReferenceDataset.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(final double[] a) throws IllegalArgumentException { final int n = getNumObservations(); final double[][] j = new double[n][]; for (int i = 0; i < n; i++) { j[i] = getModelDerivatives(getX(i), a); } return j; } }); }
Example #25
Source File: AbstractLeastSquaresOptimizerAbstractTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { return factors.getData(); } }); }
Example #26
Source File: CurveFitter.java From astor with GNU General Public License v2.0 | 5 votes |
/** * @return the model function Jacobian. */ public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { final double[][] jacobian = new double[observations.size()][]; int i = 0; for (WeightedObservedPoint observed : observations) { jacobian[i++] = f.gradient(observed.getX(), point); } return jacobian; } }); }
Example #27
Source File: AbstractLeastSquaresOptimizerAbstractTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { return factors.getData(); } }); }
Example #28
Source File: CircleVectorial.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] params) { final int n = points.size(); final Vector2D center = new Vector2D(params[0], params[1]); double dRdX = 0; double dRdY = 0; for (Vector2D pk : points) { double dk = pk.distance(center); dRdX += (center.getX() - pk.getX()) / dk; dRdY += (center.getY() - pk.getY()) / dk; } dRdX /= n; dRdY /= n; // Jacobian of the radius residuals. double[][] jacobian = new double[n][2]; for (int i = 0; i < n; i++) { final Vector2D pi = points.get(i); final double di = pi.distance(center); jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX; jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY; } return jacobian; } }); }
Example #29
Source File: StraightLineProblem.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return jacobian(point); } }); }
Example #30
Source File: MinpackTest.java From astor with GNU General Public License v2.0 | 5 votes |
public ModelFunctionJacobian getModelFunctionJacobian() { return new ModelFunctionJacobian(new MultivariateMatrixFunction() { public double[][] value(double[] point) { return computeJacobian(point); } }); }