@Test
  public void testNextGamma() {
    double[] quartiles;
    long[] counts;

    // Tests shape > 1, one case in the rejection sampling
    quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(4, 2));
    counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
      double value = randomData.nextGamma(4, 2);
      TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);

    // Tests shape <= 1, another case in the rejection sampling
    quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(0.3, 3));
    counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
      double value = randomData.nextGamma(0.3, 3);
      TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
  }
 @Test
 public void testNextWeibull() {
   double[] quartiles = TestUtils.getDistributionQuartiles(new WeibullDistribution(1.2, 2.1));
   long[] counts = new long[4];
   randomData.reSeed(1000);
   for (int i = 0; i < 1000; i++) {
     double value = randomData.nextWeibull(1.2, 2.1);
     TestUtils.updateCounts(value, counts, quartiles);
   }
   TestUtils.assertChiSquareAccept(expected, counts, 0.001);
 }
  /** test failure modes and distribution of nextExponential() */
  @Test
  public void testNextExponential() {
    try {
      randomData.nextExponential(-1);
      Assert.fail("negative mean -- expecting MathIllegalArgumentException");
    } catch (MathIllegalArgumentException ex) {
      // ignored
    }
    try {
      randomData.nextExponential(0);
      Assert.fail("zero mean -- expecting MathIllegalArgumentException");
    } catch (MathIllegalArgumentException ex) {
      // ignored
    }
    double[] quartiles;
    long[] counts;

    // Mean 1
    quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(1));
    counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
      double value = randomData.nextExponential(1);
      TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);

    // Mean 5
    quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(5));
    counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
      double value = randomData.nextExponential(5);
      TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
  }
 /** test failure modes and distribution of nextGaussian() */
 @Test
 public void testNextGaussian() {
   try {
     randomData.nextGaussian(0, 0);
     Assert.fail("zero sigma -- MathIllegalArgumentException expected");
   } catch (MathIllegalArgumentException ex) {
     // ignored
   }
   double[] quartiles = TestUtils.getDistributionQuartiles(new NormalDistribution(0, 1));
   long[] counts = new long[4];
   randomData.reSeed(1000);
   for (int i = 0; i < 1000; i++) {
     double value = randomData.nextGaussian(0, 1);
     TestUtils.updateCounts(value, counts, quartiles);
   }
   TestUtils.assertChiSquareAccept(expected, counts, 0.001);
 }