@Test void test_dhyper() { int x = 14; int m = 70; int n = 30; int k = 20; int N = m+n; double result = hypergeometric.dhyper(x, N, m, k); assertEquals(0.2140911, result, EPSILON); }
public double dhyper(int x, int N, int M, int n) { if (x > M) return 0; if (x > n) return 0; if (n - x > N - M) return 0; return Math.exp(lNchooseK(M, x) + lNchooseK(N - M, n - x) - lNchooseK(N, n)); }
Hypergeometric { public double dhyper(int x, int N, int M, int n) { if (x > M) return 0; if (x > n) return 0; if (n - x > N - M) return 0; return Math.exp(lNchooseK(M, x) + lNchooseK(N - M, n - x) - lNchooseK(N, n)); } }
Hypergeometric { public double dhyper(int x, int N, int M, int n) { if (x > M) return 0; if (x > n) return 0; if (n - x > N - M) return 0; return Math.exp(lNchooseK(M, x) + lNchooseK(N - M, n - x) - lNchooseK(N, n)); } Hypergeometric(); }
Hypergeometric { public double dhyper(int x, int N, int M, int n) { if (x > M) return 0; if (x > n) return 0; if (n - x > N - M) return 0; return Math.exp(lNchooseK(M, x) + lNchooseK(N - M, n - x) - lNchooseK(N, n)); } Hypergeometric(); double phypergeometric(int n, double p, int k, int r); double phypergeometric(int m, int m_t, int n, int n_t); double dhyper(int x, int N, int M, int n); double phyper(int x, int N, int M, int n, boolean lowerTail); double lNchooseK(int n, int k); double logfact(int i); }
Hypergeometric { public double dhyper(int x, int N, int M, int n) { if (x > M) return 0; if (x > n) return 0; if (n - x > N - M) return 0; return Math.exp(lNchooseK(M, x) + lNchooseK(N - M, n - x) - lNchooseK(N, n)); } Hypergeometric(); double phypergeometric(int n, double p, int k, int r); double phypergeometric(int m, int m_t, int n, int n_t); double dhyper(int x, int N, int M, int n); double phyper(int x, int N, int M, int n, boolean lowerTail); double lNchooseK(int n, int k); double logfact(int i);  }