@Test
public void testNextDouble() {

  double[] z = new double[100000];
  Random gen = RandomUtils.getRandom();
  for (double alpha : new double[]{1, 2, 10, 0.1, 0.01, 100}) {
    Gamma g = new Gamma(alpha, 1, gen);
    for (int i = 0; i < z.length; i++) {
      z[i] = g.nextDouble();
    }
    Arrays.sort(z);
    // verify that empirical CDF matches theoretical one pretty closely
    for (double q : seq(0.01, 1, 0.01)) {
      double p = z[(int) (q * z.length)];
      assertEquals(q, g.cdf(p), 0.01);
    }
  }
}