@Test public void testP() { System.out.println("p"); HyperGeometricDistribution instance = new HyperGeometricDistribution(100, 30, 70); instance.rand(); assertEquals(0.0, instance.p(-1), 1E-6); assertEquals(3.404564e-26, instance.p(0), 1E-30); assertEquals(7.149584e-23, instance.p(1), 1E-27); assertEquals(3.576579e-20, instance.p(2), 1E-25); assertEquals(0.1655920, instance.p(20), 1E-7); assertEquals(0.1877461, instance.p(21), 1E-7); assertEquals(0.00041413, instance.p(28), 1E-8); assertEquals(4.136376e-05, instance.p(29), 1E-10); assertEquals(1.884349e-06, instance.p(30), 1E-12); assertEquals(0.0, instance.p(31), 1E-6); }
@Override public double p(int k) { if (k < Math.max(0, m + n - N) || k > Math.min(m, n)) { return 0.0; } else { return Math.exp(logp(k)); } }
HyperGeometricDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < Math.max(0, m + n - N) || k > Math.min(m, n)) { return 0.0; } else { return Math.exp(logp(k)); } } }
HyperGeometricDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < Math.max(0, m + n - N) || k > Math.min(m, n)) { return 0.0; } else { return Math.exp(logp(k)); } } HyperGeometricDistribution(int N, int m, int n); }
HyperGeometricDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < Math.max(0, m + n - N) || k > Math.min(m, n)) { return 0.0; } else { return Math.exp(logp(k)); } } HyperGeometricDistribution(int N, int m, int n); @Override int length(); @Override double mean(); @Override double variance(); @Override double entropy(); @Override String toString(); @Override double p(int k); @Override double logp(int k); @Override double cdf(double k); @Override double quantile(double p); @Override double rand(); }
HyperGeometricDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < Math.max(0, m + n - N) || k > Math.min(m, n)) { return 0.0; } else { return Math.exp(logp(k)); } } HyperGeometricDistribution(int N, int m, int n); @Override int length(); @Override double mean(); @Override double variance(); @Override double entropy(); @Override String toString(); @Override double p(int k); @Override double logp(int k); @Override double cdf(double k); @Override double quantile(double p); @Override double rand(); final int N; final int m; final int n; }