@Test
public void beta() {

  Random r = RandomUtils.getRandom();
  for (int i = 0; i < 200; i++) {
    double alpha = -50 * Math.log1p(-r.nextDouble());
    double beta = -50 * Math.log1p(-r.nextDouble());
    double ref = Math.exp(Gamma.logGamma(alpha) + Gamma.logGamma(beta) - Gamma.logGamma(alpha + beta));
    double actual = Gamma.beta(alpha, beta);
    double err = (ref - actual) / ref;
    assertEquals("beta at (" + alpha + ", " + beta + ") relative error = " + err, 0, err, 1.0e-10);
  }
}