@Test public void testGet() { Random random = new Random(0L); final double mean = random.nextInt(5) - 2.5; final double variance = random.nextInt(5); GaussRandomProducer producer = new GaussRandomProducer(mean, variance, 1L); final int N = 50000; double meanStat = IntStream.range(0, N).mapToDouble(i -> producer.get()).sum() / N; double varianceStat = IntStream.range(0, N).mapToDouble(i -> Math.pow(producer.get() - mean, 2)).sum() / N; assertEquals(mean, meanStat, 0.01); assertEquals(variance, varianceStat, 0.1); }
@Override public Double get() { return mean + generator().nextGaussian() * Math.sqrt(variance); }
GaussRandomProducer extends RandomProducerWithGenerator { @Override public Double get() { return mean + generator().nextGaussian() * Math.sqrt(variance); } }
GaussRandomProducer extends RandomProducerWithGenerator { @Override public Double get() { return mean + generator().nextGaussian() * Math.sqrt(variance); } GaussRandomProducer();  GaussRandomProducer(long seed);  GaussRandomProducer(double mean, double variance);  GaussRandomProducer(double mean, double variance, long seed); }
GaussRandomProducer extends RandomProducerWithGenerator { @Override public Double get() { return mean + generator().nextGaussian() * Math.sqrt(variance); } GaussRandomProducer();  GaussRandomProducer(long seed);  GaussRandomProducer(double mean, double variance);  GaussRandomProducer(double mean, double variance, long seed); @Override Double get(); }
GaussRandomProducer extends RandomProducerWithGenerator { @Override public Double get() { return mean + generator().nextGaussian() * Math.sqrt(variance); } GaussRandomProducer();  GaussRandomProducer(long seed);  GaussRandomProducer(double mean, double variance);  GaussRandomProducer(double mean, double variance, long seed); @Override Double get();  }