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();  }
@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()); } }
@Test public void testSetState() throws Exception { Normal dist = new Normal(0, 1, RandomUtils.getRandom()); dist.setState(1.3, 5.9); DistributionChecks.checkDistribution(dist, breaks, 1.3, 5.9, 10000); }