@Test public void testP() { System.out.println("p"); BetaDistribution instance = new BetaDistribution(2, 5); instance.rand(); assertEquals(0, instance.p(-0.1), 1E-4); assertEquals(0, instance.p(0.0), 1E-4); assertEquals(1.9683, instance.p(0.1), 1E-4); assertEquals(2.4576, instance.p(0.2), 1E-4); assertEquals(2.1609, instance.p(0.3), 1E-4); assertEquals(1.5552, instance.p(0.4), 1E-4); assertEquals(0.9375, instance.p(0.5), 1E-4); assertEquals(0.0, instance.p(1.0), 1E-4); assertEquals(0.0, instance.p(1.5), 1E-4); }
@Override public double p(double x) { if (x < 0 || x > 1) { return 0.0; } else { return Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1) / Beta.beta(alpha, beta); } }
BetaDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double p(double x) { if (x < 0 || x > 1) { return 0.0; } else { return Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1) / Beta.beta(alpha, beta); } } }
BetaDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double p(double x) { if (x < 0 || x > 1) { return 0.0; } else { return Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1) / Beta.beta(alpha, beta); } } BetaDistribution(double alpha, double beta); }
BetaDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double p(double x) { if (x < 0 || x > 1) { return 0.0; } else { return Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1) / Beta.beta(alpha, beta); } } BetaDistribution(double alpha, double beta); static BetaDistribution fit(double[] data); double getAlpha(); double getBeta(); @Override int length(); @Override double mean(); @Override double variance(); @Override double entropy(); @Override String toString(); @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); @Override double rand(); }
BetaDistribution extends AbstractDistribution implements ExponentialFamily { @Override public double p(double x) { if (x < 0 || x > 1) { return 0.0; } else { return Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1) / Beta.beta(alpha, beta); } } BetaDistribution(double alpha, double beta); static BetaDistribution fit(double[] data); double getAlpha(); double getBeta(); @Override int length(); @Override double mean(); @Override double variance(); @Override double entropy(); @Override String toString(); @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); @Override double rand(); final double alpha; final double beta; }