@Test public void testCdf() { System.out.println("cdf"); BinomialDistribution instance = new BinomialDistribution(100, 0.3); instance.rand(); assertEquals(3.234477e-16, instance.cdf(0), 1E-20); assertEquals(1.418549e-14, instance.cdf(1), 1E-18); assertEquals(1.555566e-06, instance.cdf(10), 1E-10); assertEquals(0.01646285, instance.cdf(20), 1E-7); assertEquals(0.5491236, instance.cdf(30), 1E-7); assertEquals(1.0, instance.cdf(100), 1E-7); }
@Override public double cdf(double k) { if (k < 0) { return 0.0; } else if (k >= n) { return 1.0; } else { return Beta.regularizedIncompleteBetaFunction(n - k, k + 1, 1 - p); } }
BinomialDistribution extends DiscreteDistribution { @Override public double cdf(double k) { if (k < 0) { return 0.0; } else if (k >= n) { return 1.0; } else { return Beta.regularizedIncompleteBetaFunction(n - k, k + 1, 1 - p); } } }
BinomialDistribution extends DiscreteDistribution { @Override public double cdf(double k) { if (k < 0) { return 0.0; } else if (k >= n) { return 1.0; } else { return Beta.regularizedIncompleteBetaFunction(n - k, k + 1, 1 - p); } } BinomialDistribution(int n, double p); }
BinomialDistribution extends DiscreteDistribution { @Override public double cdf(double k) { if (k < 0) { return 0.0; } else if (k >= n) { return 1.0; } else { return Beta.regularizedIncompleteBetaFunction(n - k, k + 1, 1 - p); } } BinomialDistribution(int n, double p); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @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(); }
BinomialDistribution extends DiscreteDistribution { @Override public double cdf(double k) { if (k < 0) { return 0.0; } else if (k >= n) { return 1.0; } else { return Beta.regularizedIncompleteBetaFunction(n - k, k + 1, 1 - p); } } BinomialDistribution(int n, double p); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @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 double p; final int n; }