Package org.apache.commons.math.estimation

Examples of org.apache.commons.math.estimation.LevenbergMarquardtEstimator


                                       5.67534206273052
                                     }), false);
  }

  private void minpackTest(MinpackFunction function, boolean exceptionExpected) {
    LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
    estimator.setMaxCostEval(100 * (function.getN() + 1));
    estimator.setCostRelativeTolerance(Math.sqrt(2.22044604926e-16));
    estimator.setParRelativeTolerance(Math.sqrt(2.22044604926e-16));
    estimator.setOrthoTolerance(2.22044604926e-16);
    assertTrue(function.checkTheoreticalStartCost(estimator.getRMS(function)));
    try {
      estimator.estimate(function);
      assertFalse(exceptionExpected);
    } catch (EstimationException lsse) {
      assertTrue(exceptionExpected);
    }
    assertTrue(function.checkTheoreticalMinCost(estimator.getRMS(function)));
    assertTrue(function.checkTheoreticalMinParams());
  }
View Full Code Here


                    {410.0, 0.410522 }, {430.0, 0.382701 }, {450.0, 0.356957 }, {470.0, 0.332400 } };
            for (int i = 0; i < angles.length; ++i) {
                problem.addAngularMeasurement(3.0e7, angles[i][0], angles[i][1]);
            };

            LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
            estimator.estimate(problem);
            System.out.println("initial position: " + problem.getX0() + " " + problem.getY0());
            System.out.println("velocity: " + problem.getVx0() + " " + problem.getVy0());

        } catch (EstimationException ee) {
          System.err.println(ee.getMessage());
View Full Code Here

                                       5.67534206273052
                                     }), false);
  }

  private void minpackTest(MinpackFunction function, boolean exceptionExpected) {
    LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
    estimator.setMaxCostEval(100 * (function.getN() + 1));
    estimator.setCostRelativeTolerance(FastMath.sqrt(2.22044604926e-16));
    estimator.setParRelativeTolerance(FastMath.sqrt(2.22044604926e-16));
    estimator.setOrthoTolerance(2.22044604926e-16);
    assertTrue(function.checkTheoreticalStartCost(estimator.getRMS(function)));
    try {
      estimator.estimate(function);
      assertFalse(exceptionExpected);
    } catch (EstimationException lsse) {
      assertTrue(exceptionExpected);
    }
    assertTrue(function.checkTheoreticalMinCost(estimator.getRMS(function)));
    assertTrue(function.checkTheoreticalMinParams());
  }
View Full Code Here

                                       5.67534206273052
                                     }), false);
  }

  private void minpackTest(MinpackFunction function, boolean exceptionExpected) {
    LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
    estimator.setMaxCostEval(100 * (function.getN() + 1));
    estimator.setCostRelativeTolerance(Math.sqrt(2.22044604926e-16));
    estimator.setParRelativeTolerance(Math.sqrt(2.22044604926e-16));
    estimator.setOrthoTolerance(2.22044604926e-16);
    assertTrue(function.checkTheoreticalStartCost(estimator.getRMS(function)));
    try {
      estimator.estimate(function);
      assertFalse(exceptionExpected);
    } catch (EstimationException lsse) {
      assertTrue(exceptionExpected);
    }
    assertTrue(function.checkTheoreticalMinCost(estimator.getRMS(function)));
    assertTrue(function.checkTheoreticalMinParams());
  }
View Full Code Here

      circle.addPoint( 30.068.0);
      circle.addPoint( 50.0,  -6.0);
      circle.addPoint(110.0, -20.0);
      circle.addPoint( 35.015.0);
      circle.addPoint( 45.097.0);
      LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
      estimator.estimate(circle);
      assertTrue(estimator.getCostEvaluations() < 10);
      assertTrue(estimator.getJacobianEvaluations() < 10);
      double rms = estimator.getRMS(circle);
      assertEquals(1.768262623567235,  Math.sqrt(circle.getM()) * rms,  1.0e-10);
      assertEquals(69.96016176931406, circle.getRadius(), 1.0e-10);
      assertEquals(96.07590211815305, circle.getX(),      1.0e-10);
      assertEquals(48.13516790438953, circle.getY(),      1.0e-10);
      double[][] cov = estimator.getCovariances(circle);
      assertEquals(1.839, cov[0][0], 0.001);
      assertEquals(0.731, cov[0][1], 0.001);
      assertEquals(cov[0][1], cov[1][0], 1.0e-14);
      assertEquals(0.786, cov[1][1], 0.001);
      double[] errors = estimator.guessParametersErrors(circle);
      assertEquals(1.384, errors[0], 0.001);
      assertEquals(0.905, errors[1], 0.001);
 
      // add perfect measurements and check errors are reduced
      double cx = circle.getX();
      double cy = circle.getY();
      double  r = circle.getRadius();
      for (double d= 0; d < 2 * Math.PI; d += 0.01) {
          circle.addPoint(cx + r * Math.cos(d), cy + r * Math.sin(d));
      }
      estimator = new LevenbergMarquardtEstimator();
      estimator.estimate(circle);
      cov = estimator.getCovariances(circle);
      assertEquals(0.004, cov[0][0], 0.001);
      assertEquals(6.40e-7, cov[0][1], 1.0e-9);
      assertEquals(cov[0][1], cov[1][0], 1.0e-14);
      assertEquals(0.003, cov[1][1], 0.001);
      errors = estimator.guessParametersErrors(circle);
      assertEquals(0.004, errors[0], 0.001);
      assertEquals(0.004, errors[1], 0.001);

  }
View Full Code Here

      {-0.048837, -0.077056}, {-0.127729, -0.075338}, {-0.221271, -0.067526}
    };
    for (int i = 0; i < points.length; ++i) {
      circle.addPoint(points[i][0], points[i][1]);
    }
    LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
    estimator.estimate(circle);
    assertTrue(estimator.getCostEvaluations() < 15);
    assertTrue(estimator.getJacobianEvaluations() < 10);
    assertEquals( 0.030184491196225207, estimator.getRMS(circle), 1.0e-9);
    assertEquals( 0.2922350065939634,   circle.getRadius(), 1.0e-9);
    assertEquals(-0.15173845023862165,  circle.getX(),      1.0e-8);
    assertEquals( 0.20750021499570379,  circle.getY(),      1.0e-8);
  }
View Full Code Here

                                       5.67534206273052
                                     }), false);
  }

  private void minpackTest(MinpackFunction function, boolean exceptionExpected) {
    LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
    estimator.setMaxCostEval(100 * (function.getN() + 1));
    estimator.setCostRelativeTolerance(Math.sqrt(2.22044604926e-16));
    estimator.setParRelativeTolerance(Math.sqrt(2.22044604926e-16));
    estimator.setOrthoTolerance(2.22044604926e-16);
    assertTrue(function.checkTheoreticalStartCost(estimator.getRMS(function)));
    try {
      estimator.estimate(function);
      assertFalse(exceptionExpected);
    } catch (EstimationException lsse) {
      assertTrue(exceptionExpected);
    }
    assertTrue(function.checkTheoreticalMinCost(estimator.getRMS(function)));
    assertTrue(function.checkTheoreticalMinParams());
  }
View Full Code Here

        new LinearMeasurement(new double[] {2},
                              new EstimatedParameter[] {
                                 new EstimatedParameter("p0", 0)
                              }, 3.0)
      });
    LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
    estimator.estimate(problem);
    assertEquals(0, estimator.getRMS(problem), 1.0e-10);
    try {
        estimator.guessParametersErrors(problem);
        fail("an exception should have been thrown");
    } catch (EstimationException ee) {
        // expected behavior
    } catch (Exception e) {
        fail("wrong exception caught");
View Full Code Here

      new LinearMeasurement(new double[] { 1.0, -2.0 },
                            new EstimatedParameter[] { x[0], x[1] },
                            1.0)
    });

    LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
    estimator.estimate(problem);
    assertEquals(0, estimator.getRMS(problem), 1.0e-10);
    assertEquals(7.0, x[0].getEstimate(), 1.0e-10);
    assertEquals(3.0, x[1].getEstimate(), 1.0e-10);

  }
View Full Code Here

      new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[2] }, 2.2),
      new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[3] }, 3.3),
      new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[4] }, 4.4),
      new LinearMeasurement(new double[] {2}, new EstimatedParameter[] { p[5] }, 5.5)
    });
  LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator();
  estimator.estimate(problem);
  assertEquals(0, estimator.getRMS(problem), 1.0e-10);
  for (int i = 0; i < p.length; ++i) {
    assertEquals(0.55 * i, p[i].getEstimate(), 1.0e-10);
  }
}
View Full Code Here

TOP

Related Classes of org.apache.commons.math.estimation.LevenbergMarquardtEstimator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.