@Test public void testP() { System.out.println("p"); NegativeBinomialDistribution instance = new NegativeBinomialDistribution(3, 0.3); instance.rand(); assertEquals(0.027, instance.p(0), 1E-7); assertEquals(0.0567, instance.p(1), 1E-7); assertEquals(0.07938, instance.p(2), 1E-7); assertEquals(0.09261, instance.p(3), 1E-7); assertEquals(0.05033709, instance.p(10), 1E-7); }
@Override public double p(int k) { if (k < 0) { return 0.0; } else { return gamma(r + k) / (factorial(k) * gamma(r)) * Math.pow(p, r) * Math.pow(1 - p, k); } }
NegativeBinomialDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < 0) { return 0.0; } else { return gamma(r + k) / (factorial(k) * gamma(r)) * Math.pow(p, r) * Math.pow(1 - p, k); } } }
NegativeBinomialDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < 0) { return 0.0; } else { return gamma(r + k) / (factorial(k) * gamma(r)) * Math.pow(p, r) * Math.pow(1 - p, k); } } NegativeBinomialDistribution(double r, double p); }
NegativeBinomialDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < 0) { return 0.0; } else { return gamma(r + k) / (factorial(k) * gamma(r)) * Math.pow(p, r) * Math.pow(1 - p, k); } } NegativeBinomialDistribution(double r, double p); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override String toString(); @Override double rand(); @Override double p(int k); @Override double logp(int k); @Override double cdf(double k); @Override double quantile(double p); }
NegativeBinomialDistribution extends DiscreteDistribution { @Override public double p(int k) { if (k < 0) { return 0.0; } else { return gamma(r + k) / (factorial(k) * gamma(r)) * Math.pow(p, r) * Math.pow(1 - p, k); } } NegativeBinomialDistribution(double r, double p); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override String toString(); @Override double rand(); @Override double p(int k); @Override double logp(int k); @Override double cdf(double k); @Override double quantile(double p); final double r; final double p; }