@Test public void testLogNormalDistribution() { System.out.println("LogNormalDistribution"); MathEx.setSeed(19650218); LogNormalDistribution instance = new LogNormalDistribution(3, 2.1); double[] data = instance.rand(1000); LogNormalDistribution est = LogNormalDistribution.fit(data); assertEquals(3.04, est.mu, 1E-2); assertEquals(2.12, est.sigma, 1E-2); }
public LogNormalDistribution(double mu, double sigma) { if (sigma <= 0.0) { throw new IllegalArgumentException("Invalid sigma: " + sigma); } this.mu = mu; this.sigma = sigma; mean = Math.exp(mu + sigma * sigma / 2); var = (Math.exp(mu * mu) - 1) * Math.exp(2 * mu + sigma * sigma); entropy = 0.5 + 0.5 * Math.log(2 * Math.PI * sigma * sigma) + mu; }
LogNormalDistribution extends AbstractDistribution { public LogNormalDistribution(double mu, double sigma) { if (sigma <= 0.0) { throw new IllegalArgumentException("Invalid sigma: " + sigma); } this.mu = mu; this.sigma = sigma; mean = Math.exp(mu + sigma * sigma / 2); var = (Math.exp(mu * mu) - 1) * Math.exp(2 * mu + sigma * sigma); entropy = 0.5 + 0.5 * Math.log(2 * Math.PI * sigma * sigma) + mu; } }
LogNormalDistribution extends AbstractDistribution { public LogNormalDistribution(double mu, double sigma) { if (sigma <= 0.0) { throw new IllegalArgumentException("Invalid sigma: " + sigma); } this.mu = mu; this.sigma = sigma; mean = Math.exp(mu + sigma * sigma / 2); var = (Math.exp(mu * mu) - 1) * Math.exp(2 * mu + sigma * sigma); entropy = 0.5 + 0.5 * Math.log(2 * Math.PI * sigma * sigma) + mu; } LogNormalDistribution(double mu, double sigma); }
LogNormalDistribution extends AbstractDistribution { public LogNormalDistribution(double mu, double sigma) { if (sigma <= 0.0) { throw new IllegalArgumentException("Invalid sigma: " + sigma); } this.mu = mu; this.sigma = sigma; mean = Math.exp(mu + sigma * sigma / 2); var = (Math.exp(mu * mu) - 1) * Math.exp(2 * mu + sigma * sigma); entropy = 0.5 + 0.5 * Math.log(2 * Math.PI * sigma * sigma) + mu; } LogNormalDistribution(double mu, double sigma); static LogNormalDistribution fit(double[] data); @Override int length(); @Override double mean(); @Override double variance(); @Override double entropy(); @Override String toString(); @Override double rand(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); }
LogNormalDistribution extends AbstractDistribution { public LogNormalDistribution(double mu, double sigma) { if (sigma <= 0.0) { throw new IllegalArgumentException("Invalid sigma: " + sigma); } this.mu = mu; this.sigma = sigma; mean = Math.exp(mu + sigma * sigma / 2); var = (Math.exp(mu * mu) - 1) * Math.exp(2 * mu + sigma * sigma); entropy = 0.5 + 0.5 * Math.log(2 * Math.PI * sigma * sigma) + mu; } LogNormalDistribution(double mu, double sigma); static LogNormalDistribution fit(double[] data); @Override int length(); @Override double mean(); @Override double variance(); @Override double entropy(); @Override String toString(); @Override double rand(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); final double mu; final double sigma; }