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


Java PointVectorValuePair.getPoint方法代码示例

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


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

示例1: doTestStRD

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
public void doTestStRD(final StatisticalReferenceDataset dataset,
                       final double errParams,
                       final double errParamsSd) {
    final AbstractLeastSquaresOptimizer optimizer = createOptimizer();
    final double[] w = new double[dataset.getNumObservations()];
    Arrays.fill(w, 1);

    final double[][] data = dataset.getData();
    final double[] initial = dataset.getStartingPoint(0);
    final StatisticalReferenceDataset.LeastSquaresProblem problem = dataset.getLeastSquaresProblem();
    final PointVectorValuePair optimum
        = optimizer.optimize(new MaxEval(100),
                             problem.getModelFunction(),
                             problem.getModelFunctionJacobian(),
                             new Target(data[1]),
                             new Weight(w),
                             new InitialGuess(initial));

    final double[] actual = optimum.getPoint();
    for (int i = 0; i < actual.length; i++) {
        double expected = dataset.getParameter(i);
        double delta = FastMath.abs(errParams * expected);
        Assert.assertEquals(dataset.getName() + ", param #" + i,
                            expected, actual[i], delta);
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:AbstractLeastSquaresOptimizerAbstractTest.java

示例2: testBevington

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
/**
 * Non-linear test case: fitting of decay curve (from Chapter 8 of
 * Bevington's textbook, "Data reduction and analysis for the physical sciences").
 * XXX The expected ("reference") values may not be accurate and the tolerance too
 * relaxed for this test to be currently really useful (the issue is under
 * investigation).
 */
@Test
public void testBevington() {
    final double[][] dataPoints = {
        // column 1 = times
        { 15, 30, 45, 60, 75, 90, 105, 120, 135, 150,
          165, 180, 195, 210, 225, 240, 255, 270, 285, 300,
          315, 330, 345, 360, 375, 390, 405, 420, 435, 450,
          465, 480, 495, 510, 525, 540, 555, 570, 585, 600,
          615, 630, 645, 660, 675, 690, 705, 720, 735, 750,
          765, 780, 795, 810, 825, 840, 855, 870, 885, },
        // column 2 = measured counts
        { 775, 479, 380, 302, 185, 157, 137, 119, 110, 89,
          74, 61, 66, 68, 48, 54, 51, 46, 55, 29,
          28, 37, 49, 26, 35, 29, 31, 24, 25, 35,
          24, 30, 26, 28, 21, 18, 20, 27, 17, 17,
          14, 17, 24, 11, 22, 17, 12, 10, 13, 16,
          9, 9, 14, 21, 17, 13, 12, 18, 10, },
    };

    final BevingtonProblem problem = new BevingtonProblem();

    final int len = dataPoints[0].length;
    final double[] weights = new double[len];
    for (int i = 0; i < len; i++) {
        problem.addPoint(dataPoints[0][i],
                         dataPoints[1][i]);

        weights[i] = 1 / dataPoints[1][i];
    }

    final LevenbergMarquardtOptimizer optimizer
        = new LevenbergMarquardtOptimizer();

    final PointVectorValuePair optimum
        = optimizer.optimize(new MaxEval(100),
                             problem.getModelFunction(),
                             problem.getModelFunctionJacobian(),
                             new Target(dataPoints[1]),
                             new Weight(weights),
                             new InitialGuess(new double[] { 10, 900, 80, 27, 225 }));

    final double[] solution = optimum.getPoint();
    final double[] expectedSolution = { 10.4, 958.3, 131.4, 33.9, 205.0 };

    final double[][] covarMatrix = optimizer.computeCovariances(solution, 1e-14);
    final double[][] expectedCovarMatrix = {
        { 3.38, -3.69, 27.98, -2.34, -49.24 },
        { -3.69, 2492.26, 81.89, -69.21, -8.9 },
        { 27.98, 81.89, 468.99, -44.22, -615.44 },
        { -2.34, -69.21, -44.22, 6.39, 53.80 },
        { -49.24, -8.9, -615.44, 53.8, 929.45 }
    };

    final int numParams = expectedSolution.length;

    // Check that the computed solution is within the reference error range.
    for (int i = 0; i < numParams; i++) {
        final double error = FastMath.sqrt(expectedCovarMatrix[i][i]);
        Assert.assertEquals("Parameter " + i, expectedSolution[i], solution[i], error);
    }

    // Check that each entry of the computed covariance matrix is within 10%
    // of the reference matrix entry.
    for (int i = 0; i < numParams; i++) {
        for (int j = 0; j < numParams; j++) {
            Assert.assertEquals("Covariance matrix [" + i + "][" + j + "]",
                                expectedCovarMatrix[i][j],
                                covarMatrix[i][j],
                                FastMath.abs(0.1 * expectedCovarMatrix[i][j]));
        }
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:80,代码来源:LevenbergMarquardtOptimizerTest.java

示例3: testCircleFitting2

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
@Test
public void testCircleFitting2() {
    final double xCenter = 123.456;
    final double yCenter = 654.321;
    final double xSigma = 10;
    final double ySigma = 15;
    final double radius = 111.111;
    // The test is extremely sensitive to the seed.
    final long seed = 59421061L;
    final RandomCirclePointGenerator factory
        = new RandomCirclePointGenerator(xCenter, yCenter, radius,
                                         xSigma, ySigma,
                                         seed);
    final CircleProblem circle = new CircleProblem(xSigma, ySigma);

    final int numPoints = 10;
    for (Vector2D p : factory.generate(numPoints)) {
        circle.addPoint(p.getX(), p.getY());
    }

    // First guess for the center's coordinates and radius.
    final double[] init = { 90, 659, 115 };

    final LevenbergMarquardtOptimizer optimizer
        = new LevenbergMarquardtOptimizer();
    final PointVectorValuePair optimum = optimizer.optimize(new MaxEval(100),
                                                            circle.getModelFunction(),
                                                            circle.getModelFunctionJacobian(),
                                                            new Target(circle.target()),
                                                            new Weight(circle.weight()),
                                                            new InitialGuess(init));

    final double[] paramFound = optimum.getPoint();

    // Retrieve errors estimation.
    final double[] asymptoticStandardErrorFound = optimizer.computeSigma(paramFound, 1e-14);

    // Check that the parameters are found within the assumed error bars.
    Assert.assertEquals(xCenter, paramFound[0], asymptoticStandardErrorFound[0]);
    Assert.assertEquals(yCenter, paramFound[1], asymptoticStandardErrorFound[1]);
    Assert.assertEquals(radius, paramFound[2], asymptoticStandardErrorFound[2]);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:43,代码来源:LevenbergMarquardtOptimizerTest.java

示例4: testBevington

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
/**
 * Non-linear test case: fitting of decay curve (from Chapter 8 of
 * Bevington's textbook, "Data reduction and analysis for the physical sciences").
 * XXX The expected ("reference") values may not be accurate and the tolerance too
 * relaxed for this test to be currently really useful (the issue is under
 * investigation).
 */
@Test
public void testBevington() {
    final double[][] dataPoints = {
        // column 1 = times
        { 15, 30, 45, 60, 75, 90, 105, 120, 135, 150,
          165, 180, 195, 210, 225, 240, 255, 270, 285, 300,
          315, 330, 345, 360, 375, 390, 405, 420, 435, 450,
          465, 480, 495, 510, 525, 540, 555, 570, 585, 600,
          615, 630, 645, 660, 675, 690, 705, 720, 735, 750,
          765, 780, 795, 810, 825, 840, 855, 870, 885, },
        // column 2 = measured counts
        { 775, 479, 380, 302, 185, 157, 137, 119, 110, 89,
          74, 61, 66, 68, 48, 54, 51, 46, 55, 29,
          28, 37, 49, 26, 35, 29, 31, 24, 25, 35,
          24, 30, 26, 28, 21, 18, 20, 27, 17, 17,
          14, 17, 24, 11, 22, 17, 12, 10, 13, 16,
          9, 9, 14, 21, 17, 13, 12, 18, 10, },
    };

    final BevingtonProblem problem = new BevingtonProblem();

    final int len = dataPoints[0].length;
    final double[] weights = new double[len];
    for (int i = 0; i < len; i++) {
        problem.addPoint(dataPoints[0][i],
                         dataPoints[1][i]);

        weights[i] = 1 / dataPoints[1][i];
    }

    final LevenbergMarquardtOptimizer optimizer = LevenbergMarquardtOptimizer.create()
        .withMaxEvaluations(100)
        .withMaxIterations(20)
        .withModelAndJacobian(problem.getModelFunction(),
                              problem.getModelFunctionJacobian())
        .withTarget(dataPoints[1])
        .withWeight(new DiagonalMatrix(weights))
        .withStartPoint(new double[] { 10, 900, 80, 27, 225 });

    final PointVectorValuePair optimum = optimizer.optimize();
    final double[] solution = optimum.getPoint();
    final double[] expectedSolution = { 10.4, 958.3, 131.4, 33.9, 205.0 };

    final double[][] covarMatrix = optimizer.computeCovariances(solution, 1e-14);
    final double[][] expectedCovarMatrix = {
        { 3.38, -3.69, 27.98, -2.34, -49.24 },
        { -3.69, 2492.26, 81.89, -69.21, -8.9 },
        { 27.98, 81.89, 468.99, -44.22, -615.44 },
        { -2.34, -69.21, -44.22, 6.39, 53.80 },
        { -49.24, -8.9, -615.44, 53.8, 929.45 }
    };

    final int numParams = expectedSolution.length;

    // Check that the computed solution is within the reference error range.
    for (int i = 0; i < numParams; i++) {
        final double error = FastMath.sqrt(expectedCovarMatrix[i][i]);
        Assert.assertEquals("Parameter " + i, expectedSolution[i], solution[i], error);
    }

    // Check that each entry of the computed covariance matrix is within 10%
    // of the reference matrix entry.
    for (int i = 0; i < numParams; i++) {
        for (int j = 0; j < numParams; j++) {
            Assert.assertEquals("Covariance matrix [" + i + "][" + j + "]",
                                expectedCovarMatrix[i][j],
                                covarMatrix[i][j],
                                FastMath.abs(0.1 * expectedCovarMatrix[i][j]));
        }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:79,代码来源:LevenbergMarquardtOptimizerTest.java

示例5: testCircleFitting2

import org.apache.commons.math3.optim.PointVectorValuePair; //导入方法依赖的package包/类
@Test
public void testCircleFitting2() {
    final double xCenter = 123.456;
    final double yCenter = 654.321;
    final double xSigma = 10;
    final double ySigma = 15;
    final double radius = 111.111;
    // The test is extremely sensitive to the seed.
    final long seed = 59421061L;
    final RandomCirclePointGenerator factory
        = new RandomCirclePointGenerator(xCenter, yCenter, radius,
                                         xSigma, ySigma,
                                         seed);
    final CircleProblem circle = new CircleProblem(xSigma, ySigma);

    final int numPoints = 10;
    for (Vector2D p : factory.generate(numPoints)) {
        circle.addPoint(p.getX(), p.getY());
    }

    // First guess for the center's coordinates and radius.
    final double[] init = { 90, 659, 115 };

    final LevenbergMarquardtOptimizer optimizer = LevenbergMarquardtOptimizer.create()
        .withMaxEvaluations(100)
        .withMaxIterations(50)
        .withModelAndJacobian(circle.getModelFunction(),
                              circle.getModelFunctionJacobian())
        .withTarget(circle.target())
        .withWeight(new DiagonalMatrix(circle.weight()))
        .withStartPoint(init);

    final PointVectorValuePair optimum = optimizer.optimize();
    final double[] paramFound = optimum.getPoint();

    // Retrieve errors estimation.
    final double[] asymptoticStandardErrorFound = optimizer.computeSigma(paramFound, 1e-14);

    // Check that the parameters are found within the assumed error bars.
    Assert.assertEquals(xCenter, paramFound[0], asymptoticStandardErrorFound[0]);
    Assert.assertEquals(yCenter, paramFound[1], asymptoticStandardErrorFound[1]);
    Assert.assertEquals(radius, paramFound[2], asymptoticStandardErrorFound[2]);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:44,代码来源:LevenbergMarquardtOptimizerTest.java


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