@Test public void testLogP() { System.out.println("logP"); GeometricDistribution instance = new GeometricDistribution(0.3); instance.rand(); assertEquals(Math.log(0.3), instance.logp(0), 1E-6); assertEquals(Math.log(0.21), instance.logp(1), 1E-6); assertEquals(Math.log(0.147), instance.logp(2), 1E-6); assertEquals(Math.log(0.1029), instance.logp(3), 1E-6); assertEquals(Math.log(0.07203), instance.logp(4), 1E-6); assertEquals(Math.log(0.008474257), instance.logp(10), 1E-6); assertEquals(Math.log(0.0002393768), instance.logp(20), 1E-6); }
@Override public double logp(int k) { if (k < 0) { return Double.NEGATIVE_INFINITY; } else { return k * Math.log(1 - p) + Math.log(p); } }
GeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k < 0) { return Double.NEGATIVE_INFINITY; } else { return k * Math.log(1 - p) + Math.log(p); } } }
GeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k < 0) { return Double.NEGATIVE_INFINITY; } else { return k * Math.log(1 - p) + Math.log(p); } } GeometricDistribution(double p); }
GeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k < 0) { return Double.NEGATIVE_INFINITY; } else { return k * Math.log(1 - p) + Math.log(p); } } GeometricDistribution(double p); static GeometricDistribution fit(int[] data); @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); @Override DiscreteMixture.Component M(int[] x, double[] posteriori); }
GeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k < 0) { return Double.NEGATIVE_INFINITY; } else { return k * Math.log(1 - p) + Math.log(p); } } GeometricDistribution(double p); static GeometricDistribution fit(int[] data); @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); @Override DiscreteMixture.Component M(int[] x, double[] posteriori); final double p; }