Stat { public static double logNfact(long n) { if (n <= 0) return 0; if (n < 100) return logNfactExact(n); double P = Math.log((2 * n + 1.0 / 3) * Math.PI) / 2 + n * Math.log(n / Math.E); return P; }  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 testLogNfact() { long arg1s[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; double ress[] = {0,0,0.693,1.792,3.178,4.787,6.579,8.525,10.605,12.802,15.104,17.502,19.987,22.552,25.191,27.899}; List<ModelLongDouble> testData = TestDataManager.fillTestCasesLongDouble(arg1s, ress); for (ModelLongDouble datum : testData) { assertEquals(datum.getRes(), Stat.logNfact(datum.getArg1()), TestDataManager.DELTA_DOUBLE); } }