Пример #1
0
  @Test
  /** Test of integrator for the sine function. */
  public void testSinFunction() {

    UnivariateFunction f = new Gaussian(10, 2);
    UnivariateIntegrator integrator = new SimpsonIntegrator();
    double a, b, expected, tolerance, result;

    a = 8;
    b = 12;
    expected = 0.68269;
    tolerance = 0.00001;

    tolerance = Math.abs(expected * integrator.getRelativeAccuracy());
    result = integrator.integrate(MAX_EVAL, f, a, b);
    assertEquals(expected, result, tolerance);

    log.info(
        "Result: "
            + result
            + ", tolerance: "
            + tolerance
            + " - Relative accuracy: "
            + integrator.getRelativeAccuracy()
            + " - Absolute accuracy: "
            + integrator.getAbsoluteAccuracy()
            + " - Iterations: "
            + integrator.getIterations());

    NormalDistribution distribution = new NormalDistribution(10, 2);
    result = distribution.cumulativeProbability(a, b);
    log.info("Distribution result: " + result);
  }