@Test public void testLogP() { System.out.println("logP"); GaussianDistribution instance = new GaussianDistribution(4.0, 3.0); instance.rand(); assertEquals(-12.90644, instance.logp(-10), 1E-5); assertEquals(-4.017551, instance.logp(-2), 1E-6); assertEquals(-2.517551, instance.logp(1.0), 1E-6); assertEquals(-2.239773, instance.logp(2.0), 1E-6); assertEquals(-2.073106, instance.logp(3.0), 1E-6); assertEquals(-2.017551, instance.logp(4.0), 1E-6); assertEquals(-4.017551, instance.logp(10), 1E-6); assertEquals(-16.23977, instance.logp(20), 1E-5); }
@Override public double logp(double x) { if (sigma == 0) { if (x == mu) { return 0.0; } else { return Double.NEGATIVE_INFINITY; } } double d = x - mu; return -0.5 * d * d / variance - pdfConstant; }
GaussianDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double logp(double x) { if (sigma == 0) { if (x == mu) { return 0.0; } else { return Double.NEGATIVE_INFINITY; } } double d = x - mu; return -0.5 * d * d / variance - pdfConstant; } }
GaussianDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double logp(double x) { if (sigma == 0) { if (x == mu) { return 0.0; } else { return Double.NEGATIVE_INFINITY; } } double d = x - mu; return -0.5 * d * d / variance - pdfConstant; } GaussianDistribution(double mu, double sigma); }
GaussianDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double logp(double x) { if (sigma == 0) { if (x == mu) { return 0.0; } else { return Double.NEGATIVE_INFINITY; } } double d = x - mu; return -0.5 * d * d / variance - pdfConstant; } GaussianDistribution(double mu, double sigma); static GaussianDistribution fit(double[] data); static GaussianDistribution getInstance(); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override String toString(); @Override double rand(); double randInverseCDF(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); @Override Mixture.Component M(double[] x, double[] posteriori); }
GaussianDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double logp(double x) { if (sigma == 0) { if (x == mu) { return 0.0; } else { return Double.NEGATIVE_INFINITY; } } double d = x - mu; return -0.5 * d * d / variance - pdfConstant; } GaussianDistribution(double mu, double sigma); static GaussianDistribution fit(double[] data); static GaussianDistribution getInstance(); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override String toString(); @Override double rand(); double randInverseCDF(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); @Override Mixture.Component M(double[] x, double[] posteriori); final double mu; final double sigma; }