Examples of nextRandom()


Examples of com.opengamma.analytics.math.statistics.distribution.ChiSquareDistribution.nextRandom()

    final int n = 500000;
    final double k = 1.34;
    final ProbabilityDistribution<Double> p1 = new ChiSquareDistribution(k, new MersenneTwister64(MersenneTwister.DEFAULT_SEED));
    final double[] x = new double[n];
    for (int i = 0; i < n; i++) {
      x[i] = p1.nextRandom();
    }
    final ChiSquareDistribution p2 = (ChiSquareDistribution) CALCULATOR.evaluate(x);
    assertEquals(p2.getDegreesOfFreedom(), k, 2.5e-2);
  }
}
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.distribution.GammaDistribution.nextRandom()

    final double k = 0.97;
    final double theta = 0.46;
    final ProbabilityDistribution<Double> p1 = new GammaDistribution(k, theta, new MersenneTwister(MersenneTwister.DEFAULT_SEED));
    final double[] x = new double[n];
    for (int i = 0; i < n; i++) {
      x[i] = p1.nextRandom();
    }
    final GammaDistribution p2 = (GammaDistribution) CALCULATOR.evaluate(x);
    final double eps = 0.025;
    assertEquals(p2.getK(), k, eps);
    assertEquals(p2.getTheta(), theta, eps);
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.distribution.LaplaceDistribution.nextRandom()

    final double b = 1.4;
    final ProbabilityDistribution<Double> distribution = new LaplaceDistribution(mu, b, new MersenneTwister64(MersenneTwister.DEFAULT_SEED));
    final int n = 500000;
    final double[] x = new double[n];
    for (int i = 0; i < n; i++) {
      x[i] = distribution.nextRandom();
    }
    final LaplaceDistribution result = (LaplaceDistribution) ESTIMATOR.evaluate(x);
    final double eps = 1e-2;
    assertEquals(1, result.getB() / b, eps);
    assertEquals(1, result.getMu() / mu, eps);
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.distribution.NormalDistribution.nextRandom()

    final double mu = -1.3;
    final double sigma = 0.4;
    final ProbabilityDistribution<Double> p1 = new NormalDistribution(mu, sigma, new MersenneTwister64(MersenneTwister.DEFAULT_SEED));
    final double[] x = new double[n];
    for (int i = 0; i < n; i++) {
      x[i] = p1.nextRandom();
    }
    final NormalDistribution p2 = (NormalDistribution) ESTIMATOR.evaluate(x);
    assertEquals(p2.getMean(), mu, eps);
    assertEquals(p2.getStandardDeviation(), sigma, eps);
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.distribution.NormalDistribution.nextRandom()

    final double mu = 4.5;
    final double sigma = 0.86;
    final ProbabilityDistribution<Double> p1 = new NormalDistribution(mu, sigma, new MersenneTwister64(MersenneTwister.DEFAULT_SEED));
    final double[] x = new double[n];
    for (int i = 0; i < n; i++) {
      x[i] = p1.nextRandom();
    }
    final NormalDistribution p2 = (NormalDistribution) CALCULATOR.evaluate(x);
    assertEquals(p2.getMean(), mu, 2.5e-2);
    assertEquals(p2.getStandardDeviation(), sigma, 2.5e-2);
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.distribution.StudentTDistribution.nextRandom()

    final double eps = 5e-2;
    final double nu = 5.4;
    final ProbabilityDistribution<Double> p1 = new StudentTDistribution(nu, new MersenneTwister64(MersenneTwister.DEFAULT_SEED));
    final double[] x = new double[n];
    for (int i = 0; i < n; i++) {
      x[i] = p1.nextRandom();
    }
    final StudentTDistribution p2 = (StudentTDistribution) ESTIMATOR.evaluate(x);
    assertEquals(p2.getDegreesOfFreedom(), nu, eps);
  }
}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.