Stat { public static double beta(int a, int b) { return Math.exp(logNfactExact(a - 1) + logNfactExact(b - 1) - logNfactExact(a + b - 1)); }  static double hg(long D, long gt, long S); static double hgapprox(long D, long gt, int S); static double beta_CDF(double x, int a, int b); static double incompleteBeta(double x, int a, int b); static double beta(int a, int b); static double ix(double x, int a, int b); static double logNfact(long n); static long nFactExact(long n); static double binom(int n, int i); static double logBinom(int n, int i); static double logoggs(double p); static double logit(double logodds); static void main(String[] args);  }
@Test public final void testBeta() { RangePairIntInt rp = new RangePairIntInt(); rp.setRange1(1, 5); rp.setRange2(1, 5); double ress[] = { 1, 0.5, 0.333, 0.25, 0.2, 0.5, 0.167, 0.083, 0.05, 0.033, 0.333, 0.083, 0.033, 0.017, 9.524 / 1000, 0.25, 0.05, 0.017, 7.143 / 1000, 3.571 / 1000, 0.2, 0.033, 9.524 / 1000, 3.571 / 1000, 1.587 / 1000 }; List<ModelIntIntDouble> testData = TestDataManager.fillTestCasesIntIntDouble(rp,ress); for(ModelIntIntDouble datum : testData) { assertEquals(datum.getRes(), Stat.beta(datum.getArg1(), datum.getArg2()),TestDataManager.DELTA_DOUBLE); } }