当前位置: 首页>>代码示例>>Java>>正文


Java PointVectorValuePair.getPointRef方法代码示例

本文整理汇总了Java中org.apache.commons.math3.optim.PointVectorValuePair.getPointRef方法的典型用法代码示例。如果您正苦于以下问题:Java PointVectorValuePair.getPointRef方法的具体用法?Java PointVectorValuePair.getPointRef怎么用?Java PointVectorValuePair.getPointRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.optim.PointVectorValuePair的用法示例。


在下文中一共展示了PointVectorValuePair.getPointRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCircleFittingBadInit

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
@Test
public void testCircleFittingBadInit() {
    CircleVectorial circle = new CircleVectorial();
    double[][] points = circlePoints;
    double[] target = new double[points.length];
    Arrays.fill(target, 0);
    double[] weights = new double[points.length];
    Arrays.fill(weights, 2);
    for (int i = 0; i < points.length; ++i) {
        circle.addPoint(points[i][0], points[i][1]);
    }
    AbstractLeastSquaresOptimizer optimizer = createOptimizer();
    PointVectorValuePair optimum
        = optimizer.optimize(new MaxEval(100),
                             circle.getModelFunction(),
                             circle.getModelFunctionJacobian(),
                             new Target(target),
                             new Weight(weights),
                             new InitialGuess(new double[] { -12, -12 }));
    Vector2D center = new Vector2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
    Assert.assertTrue(optimizer.getEvaluations() < 25);
    Assert.assertEquals( 0.043, optimizer.getRMS(), 1e-3);
    Assert.assertEquals( 0.292235,  circle.getRadius(center), 1e-6);
    Assert.assertEquals(-0.151738,  center.getX(),            1e-6);
    Assert.assertEquals( 0.2075001, center.getY(),            1e-6);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java

示例2: fit

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
/**
 * Fit a curve.
 * This method compute the coefficients of the curve that best
 * fit the sample of observed points previously given through calls
 * to the {@link #addObservedPoint(WeightedObservedPoint)
 * addObservedPoint} method.
 *
 * @param f parametric function to fit.
 * @param initialGuess first guess of the function parameters.
 * @param maxEval Maximum number of function evaluations.
 * @return the fitted parameters.
 * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
 * if the number of allowed evaluations is exceeded.
 * @throws org.apache.commons.math3.exception.DimensionMismatchException
 * if the start point dimension is wrong.
 * @since 3.0
 */
public double[] fit(int maxEval, T f,
                    final double[] initialGuess) {
    // Prepare least squares problem.
    double[] target  = new double[observations.size()];
    double[] weights = new double[observations.size()];
    int i = 0;
    for (WeightedObservedPoint point : observations) {
        target[i]  = point.getY();
        weights[i] = point.getWeight();
        ++i;
    }

    // Input to the optimizer: the model and its Jacobian.
    final TheoreticalValuesFunction model = new TheoreticalValuesFunction(f);

    // Perform the fit.
    final PointVectorValuePair optimum
        = optimizer.optimize(new MaxEval(maxEval),
                             model.getModelFunction(),
                             model.getModelFunctionJacobian(),
                             new Target(target),
                             new Weight(weights),
                             new InitialGuess(initialGuess));
    // Extract the coefficients.
    return optimum.getPointRef();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:44,代码来源:CurveFitter.java

示例3: checkTheoreticalMinParams

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
public void checkTheoreticalMinParams(PointVectorValuePair optimum) {
    double[] params = optimum.getPointRef();
    if (theoreticalMinParams != null) {
        for (int i = 0; i < theoreticalMinParams.length; ++i) {
            double mi = theoreticalMinParams[i];
            double vi = params[i];
            Assert.assertEquals(mi, vi, paramsAccuracy * (1.0 + FastMath.abs(mi)));
        }
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:11,代码来源:MinpackTest.java

示例4: testCircleFitting

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
@Test
public void testCircleFitting() {
    CircleVectorial circle = new CircleVectorial();
    circle.addPoint( 30,  68);
    circle.addPoint( 50,  -6);
    circle.addPoint(110, -20);
    circle.addPoint( 35,  15);
    circle.addPoint( 45,  97);
    AbstractLeastSquaresOptimizer optimizer = createOptimizer();
    PointVectorValuePair optimum
        = optimizer.optimize(new MaxEval(100),
                             circle.getModelFunction(),
                             circle.getModelFunctionJacobian(),
                             new Target(new double[] { 0, 0, 0, 0, 0 }),
                             new Weight(new double[] { 1, 1, 1, 1, 1 }),
                             new InitialGuess(new double[] { 98.680, 47.345 }));
    Assert.assertTrue(optimizer.getEvaluations() < 10);
    double rms = optimizer.getRMS();
    Assert.assertEquals(1.768262623567235,  FastMath.sqrt(circle.getN()) * rms,  1e-10);
    Vector2D center = new Vector2D(optimum.getPointRef()[0], optimum.getPointRef()[1]);
    Assert.assertEquals(69.96016176931406, circle.getRadius(center), 1e-6);
    Assert.assertEquals(96.07590211815305, center.getX(),            1e-6);
    Assert.assertEquals(48.13516790438953, center.getY(),            1e-6);
    double[][] cov = optimizer.computeCovariances(optimum.getPoint(), 1e-14);
    Assert.assertEquals(1.839, cov[0][0], 0.001);
    Assert.assertEquals(0.731, cov[0][1], 0.001);
    Assert.assertEquals(cov[0][1], cov[1][0], 1e-14);
    Assert.assertEquals(0.786, cov[1][1], 0.001);

    // add perfect measurements and check errors are reduced
    double  r = circle.getRadius(center);
    for (double d= 0; d < 2 * FastMath.PI; d += 0.01) {
        circle.addPoint(center.getX() + r * FastMath.cos(d), center.getY() + r * FastMath.sin(d));
    }
    double[] target = new double[circle.getN()];
    Arrays.fill(target, 0);
    double[] weights = new double[circle.getN()];
    Arrays.fill(weights, 2);
    optimum = optimizer.optimize(new MaxEval(100),
                                 circle.getModelFunction(),
                                 circle.getModelFunctionJacobian(),
                                 new Target(target),
                                 new Weight(weights),
                                 new InitialGuess(new double[] { 98.680, 47.345 }));
    cov = optimizer.computeCovariances(optimum.getPoint(), 1e-14);
    Assert.assertEquals(0.0016, cov[0][0], 0.001);
    Assert.assertEquals(3.2e-7, cov[0][1], 1e-9);
    Assert.assertEquals(cov[0][1], cov[1][0], 1e-14);
    Assert.assertEquals(0.0016, cov[1][1], 0.001);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:51,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java


注:本文中的org.apache.commons.math3.optim.PointVectorValuePair.getPointRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。