@Test public void testLogP() { System.out.println("logP"); ShiftedGeometricDistribution instance = new ShiftedGeometricDistribution(0.3); instance.rand(); assertEquals(Math.log(0.3), instance.logp(1), 1E-6); assertEquals(Math.log(0.21), instance.logp(2), 1E-6); assertEquals(Math.log(0.147), instance.logp(3), 1E-6); assertEquals(Math.log(0.1029), instance.logp(4), 1E-6); assertEquals(Math.log(0.07203), instance.logp(5), 1E-6); assertEquals(Math.log(0.008474257), instance.logp(11), 1E-6); assertEquals(Math.log(0.0002393768), instance.logp(21), 1E-6); }
@Override public double logp(int k) { if (k <= 0) { return Double.NEGATIVE_INFINITY; } else { return (k - 1) * Math.log(1 - p) + Math.log(p); } }
ShiftedGeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k <= 0) { return Double.NEGATIVE_INFINITY; } else { return (k - 1) * Math.log(1 - p) + Math.log(p); } } }
ShiftedGeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k <= 0) { return Double.NEGATIVE_INFINITY; } else { return (k - 1) * Math.log(1 - p) + Math.log(p); } } ShiftedGeometricDistribution(double p); }
ShiftedGeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k <= 0) { return Double.NEGATIVE_INFINITY; } else { return (k - 1) * Math.log(1 - p) + Math.log(p); } } ShiftedGeometricDistribution(double p); static ShiftedGeometricDistribution 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); }
ShiftedGeometricDistribution extends DiscreteDistribution implements DiscreteExponentialFamily { @Override public double logp(int k) { if (k <= 0) { return Double.NEGATIVE_INFINITY; } else { return (k - 1) * Math.log(1 - p) + Math.log(p); } } ShiftedGeometricDistribution(double p); static ShiftedGeometricDistribution 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; }