@Test public void testGauss() { VectorGenerator gen = VectorGeneratorPrimitives.gauss(VectorUtils.of(2., 100.), VectorUtils.of(20., 1.), 10L); final double[] mean = new double[] {2., 100.}; final double[] variance = new double[] {20., 1.}; final int N = 50000; Vector meanStat = IntStream.range(0, N).mapToObj(i -> gen.get()).reduce(Vector::plus).get().times(1. / N); Vector varianceStat = IntStream.range(0, N).mapToObj(i -> gen.get().minus(meanStat)) .map(v -> v.times(v)).reduce(Vector::plus).get().times(1. / N); assertArrayEquals(mean, meanStat.asArray(), 0.1); assertArrayEquals(variance, varianceStat.asArray(), 0.1); }
public static VectorGenerator gauss(Vector means, Vector variances, Long seed) { A.notEmpty(means.asArray(), "mean.size() != 0"); A.ensure(means.size() == variances.size(), "mean.size() == variances.size()"); RandomProducer[] producers = new RandomProducer[means.size()]; for (int i = 0; i < producers.length; i++) producers[i] = new GaussRandomProducer(means.get(i), variances.get(i), seed *= 2); return RandomProducer.vectorize(producers); }
VectorGeneratorPrimitives { public static VectorGenerator gauss(Vector means, Vector variances, Long seed) { A.notEmpty(means.asArray(), "mean.size() != 0"); A.ensure(means.size() == variances.size(), "mean.size() == variances.size()"); RandomProducer[] producers = new RandomProducer[means.size()]; for (int i = 0; i < producers.length; i++) producers[i] = new GaussRandomProducer(means.get(i), variances.get(i), seed *= 2); return RandomProducer.vectorize(producers); } }
VectorGeneratorPrimitives { public static VectorGenerator gauss(Vector means, Vector variances, Long seed) { A.notEmpty(means.asArray(), "mean.size() != 0"); A.ensure(means.size() == variances.size(), "mean.size() == variances.size()"); RandomProducer[] producers = new RandomProducer[means.size()]; for (int i = 0; i < producers.length; i++) producers[i] = new GaussRandomProducer(means.get(i), variances.get(i), seed *= 2); return RandomProducer.vectorize(producers); }  }
VectorGeneratorPrimitives { public static VectorGenerator gauss(Vector means, Vector variances, Long seed) { A.notEmpty(means.asArray(), "mean.size() != 0"); A.ensure(means.size() == variances.size(), "mean.size() == variances.size()"); RandomProducer[] producers = new RandomProducer[means.size()]; for (int i = 0; i < producers.length; i++) producers[i] = new GaussRandomProducer(means.get(i), variances.get(i), seed *= 2); return RandomProducer.vectorize(producers); }  static VectorGenerator gauss(Vector means, Vector variances, Long seed); static VectorGenerator gauss(Vector means, Vector variances); static VectorGenerator ring(double radius, double fromAngle, double toAngle); static VectorGenerator ring(double radius, double fromAngle, double toAngle, long seed); static VectorGenerator parallelogram(Vector bounds); static VectorGenerator parallelogram(Vector bounds, long seed); static VectorGenerator circle(double radius); static VectorGenerator circle(double radius, long seed); static VectorGenerator zero(int size); static VectorGenerator constant(Vector v); }
VectorGeneratorPrimitives { public static VectorGenerator gauss(Vector means, Vector variances, Long seed) { A.notEmpty(means.asArray(), "mean.size() != 0"); A.ensure(means.size() == variances.size(), "mean.size() == variances.size()"); RandomProducer[] producers = new RandomProducer[means.size()]; for (int i = 0; i < producers.length; i++) producers[i] = new GaussRandomProducer(means.get(i), variances.get(i), seed *= 2); return RandomProducer.vectorize(producers); }  static VectorGenerator gauss(Vector means, Vector variances, Long seed); static VectorGenerator gauss(Vector means, Vector variances); static VectorGenerator ring(double radius, double fromAngle, double toAngle); static VectorGenerator ring(double radius, double fromAngle, double toAngle, long seed); static VectorGenerator parallelogram(Vector bounds); static VectorGenerator parallelogram(Vector bounds, long seed); static VectorGenerator circle(double radius); static VectorGenerator circle(double radius, long seed); static VectorGenerator zero(int size); static VectorGenerator constant(Vector v);  }