@Test public void testSample() throws Exception { double[] data = new double[10001]; Sampler<Double> sampler = new Normal(); for (int i = 0; i < data.length; i++) { data[i] = sampler.sample(); } Arrays.sort(data); NormalDistribution reference = new NormalDistribution(RandomUtils.getRandom().getRandomGenerator(), 0, 1, NormalDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY); assertEquals("Median", reference.inverseCumulativeProbability(0.5), data[5000], 0.04); }
@Override public Double sample() { return rand.nextGaussian() * sd + mean; }
Normal extends AbstractSamplerFunction { @Override public Double sample() { return rand.nextGaussian() * sd + mean; } }
Normal extends AbstractSamplerFunction { @Override public Double sample() { return rand.nextGaussian() * sd + mean; } Normal();  Normal(double mean, double sd); }
Normal extends AbstractSamplerFunction { @Override public Double sample() { return rand.nextGaussian() * sd + mean; } Normal();  Normal(double mean, double sd); @Override Double sample(); }
Normal extends AbstractSamplerFunction { @Override public Double sample() { return rand.nextGaussian() * sd + mean; } Normal();  Normal(double mean, double sd); @Override Double sample();  }