@Test public void testVariance() { System.out.println("variance"); HyperGeometricDistribution instance = new HyperGeometricDistribution(100, 30, 70); instance.rand(); assertEquals(4.454545, instance.variance(), 1E-6); instance = new HyperGeometricDistribution(100, 30, 80); instance.rand(); assertEquals(3.393939, instance.variance(), 1E-6); instance = new HyperGeometricDistribution(100, 30, 60); instance.rand(); assertEquals(5.090909, instance.variance(), 1E-6); }
@Override public double variance() { double r = (double) m / N; return n * (N - n) * r * (1 - r) / (N - 1); }
HyperGeometricDistribution extends DiscreteDistribution { @Override public double variance() { double r = (double) m / N; return n * (N - n) * r * (1 - r) / (N - 1); } }
HyperGeometricDistribution extends DiscreteDistribution { @Override public double variance() { double r = (double) m / N; return n * (N - n) * r * (1 - r) / (N - 1); } HyperGeometricDistribution(int N, int m, int n); }
HyperGeometricDistribution extends DiscreteDistribution { @Override public double variance() { double r = (double) m / N; return n * (N - n) * r * (1 - r) / (N - 1); } 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 variance() { double r = (double) m / N; return n * (N - n) * r * (1 - r) / (N - 1); } 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; }