@Test public void testGaussianDistribution() { System.out.println("GaussianDistribution"); MathEx.setSeed(19650218); GaussianDistribution instance = new GaussianDistribution(3, 2.1); double[] data = instance.rand(1000); GaussianDistribution est = GaussianDistribution.fit(data); assertEquals(3.05, est.mu, 1E-2); assertEquals(2.13, est.sigma, 1E-2); }
public GaussianDistribution(double mu, double sigma) { this.mu = mu; this.sigma = sigma; variance = sigma * sigma; entropy = Math.log(sigma) + LOG2PIE_2; pdfConstant = Math.log(sigma) + LOG2PI_2; }
GaussianDistribution extends AbstractDistribution implements ExponentialFamily { public GaussianDistribution(double mu, double sigma) { this.mu = mu; this.sigma = sigma; variance = sigma * sigma; entropy = Math.log(sigma) + LOG2PIE_2; pdfConstant = Math.log(sigma) + LOG2PI_2; } }
GaussianDistribution extends AbstractDistribution implements ExponentialFamily { public GaussianDistribution(double mu, double sigma) { this.mu = mu; this.sigma = sigma; variance = sigma * sigma; entropy = Math.log(sigma) + LOG2PIE_2; pdfConstant = Math.log(sigma) + LOG2PI_2; } GaussianDistribution(double mu, double sigma); }
GaussianDistribution extends AbstractDistribution implements ExponentialFamily { public GaussianDistribution(double mu, double sigma) { this.mu = mu; this.sigma = sigma; variance = sigma * sigma; entropy = Math.log(sigma) + LOG2PIE_2; pdfConstant = Math.log(sigma) + LOG2PI_2; } 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 { public GaussianDistribution(double mu, double sigma) { this.mu = mu; this.sigma = sigma; variance = sigma * sigma; entropy = Math.log(sigma) + LOG2PIE_2; pdfConstant = Math.log(sigma) + LOG2PI_2; } 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; }