@Test public void consistency() { Random gen = RandomUtils.getRandom(); double offset = 0; double scale = 1; Normal dist = new Normal(offset, scale, RandomUtils.getRandom()); for (int k = 0; k < 20; k++) { dist.setState(offset, scale); DistributionChecks.checkDistribution(dist, breaks, offset, scale, 10000); offset = gen.nextGaussian(); scale = Math.exp(3 * gen.nextGaussian()); } }
public final void setState(double mean, double standardDeviation) { if (mean != this.mean || standardDeviation != this.standardDeviation) { this.mean = mean; this.standardDeviation = standardDeviation; this.variance = standardDeviation * standardDeviation; this.cacheFilled = false; this.normalizer = 1.0 / Math.sqrt(2.0 * Math.PI * variance); } }
Normal extends AbstractContinousDistribution { public final void setState(double mean, double standardDeviation) { if (mean != this.mean || standardDeviation != this.standardDeviation) { this.mean = mean; this.standardDeviation = standardDeviation; this.variance = standardDeviation * standardDeviation; this.cacheFilled = false; this.normalizer = 1.0 / Math.sqrt(2.0 * Math.PI * variance); } } }
Normal extends AbstractContinousDistribution { public final void setState(double mean, double standardDeviation) { if (mean != this.mean || standardDeviation != this.standardDeviation) { this.mean = mean; this.standardDeviation = standardDeviation; this.variance = standardDeviation * standardDeviation; this.cacheFilled = false; this.normalizer = 1.0 / Math.sqrt(2.0 * Math.PI * variance); } } Normal(double mean, double standardDeviation, Random randomGenerator); }
Normal extends AbstractContinousDistribution { public final void setState(double mean, double standardDeviation) { if (mean != this.mean || standardDeviation != this.standardDeviation) { this.mean = mean; this.standardDeviation = standardDeviation; this.variance = standardDeviation * standardDeviation; this.cacheFilled = false; this.normalizer = 1.0 / Math.sqrt(2.0 * Math.PI * variance); } } Normal(double mean, double standardDeviation, Random randomGenerator); @Override double cdf(double x); @Override double pdf(double x); @Override double nextDouble(); @Override final void setRandomGenerator(Random randomGenerator); final void setState(double mean, double standardDeviation); @Override String toString(); }
Normal extends AbstractContinousDistribution { public final void setState(double mean, double standardDeviation) { if (mean != this.mean || standardDeviation != this.standardDeviation) { this.mean = mean; this.standardDeviation = standardDeviation; this.variance = standardDeviation * standardDeviation; this.cacheFilled = false; this.normalizer = 1.0 / Math.sqrt(2.0 * Math.PI * variance); } } Normal(double mean, double standardDeviation, Random randomGenerator); @Override double cdf(double x); @Override double pdf(double x); @Override double nextDouble(); @Override final void setRandomGenerator(Random randomGenerator); final void setState(double mean, double standardDeviation); @Override String toString();  }