Gamma extends AbstractContinousDistribution { @Override public double nextDouble() { return nextDouble(alpha, rate); } Gamma(double alpha, double rate, Random randomGenerator); @Override double cdf(double x); @Override double nextDouble(); double nextDouble(double alpha, double rate); @Override double pdf(double x); @Override String toString(); static double logGamma(double x);  }
@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); for (double q : seq(0.01, 1, 0.01)) { double p = z[(int) (q * z.length)]; assertEquals(q, g.cdf(p), 0.01); } } }