@Test public void testLogP() { System.out.println("logP"); BernoulliDistribution instance = new BernoulliDistribution(0.3); instance.rand(); assertEquals(Math.log(0.7), instance.logp(0), 1E-7); assertEquals(Math.log(0.3), instance.logp(1), 1E-7); }
@Override public double logp(int k) { if (k == 0) { return Math.log(q); } else if (k == 1) { return Math.log(p); } else { return Double.NEGATIVE_INFINITY; } }
BernoulliDistribution extends DiscreteDistribution { @Override public double logp(int k) { if (k == 0) { return Math.log(q); } else if (k == 1) { return Math.log(p); } else { return Double.NEGATIVE_INFINITY; } } }
BernoulliDistribution extends DiscreteDistribution { @Override public double logp(int k) { if (k == 0) { return Math.log(q); } else if (k == 1) { return Math.log(p); } else { return Double.NEGATIVE_INFINITY; } } BernoulliDistribution(double p);  BernoulliDistribution(boolean[] data); }
BernoulliDistribution extends DiscreteDistribution { @Override public double logp(int k) { if (k == 0) { return Math.log(q); } else if (k == 1) { return Math.log(p); } else { return Double.NEGATIVE_INFINITY; } } BernoulliDistribution(double p);  BernoulliDistribution(boolean[] data); static BernoulliDistribution fit(int[] data); @Override int length(); @Override double mean(); @Override double variance(); @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); }
BernoulliDistribution extends DiscreteDistribution { @Override public double logp(int k) { if (k == 0) { return Math.log(q); } else if (k == 1) { return Math.log(p); } else { return Double.NEGATIVE_INFINITY; } } BernoulliDistribution(double p);  BernoulliDistribution(boolean[] data); static BernoulliDistribution fit(int[] data); @Override int length(); @Override double mean(); @Override double variance(); @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 p; final double q; }