@Test public void testRadius() { MultiNormal gen = new MultiNormal(0.1, new DenseVector(10)); OnlineSummarizer s = new OnlineSummarizer(); for (int i = 0; i < 10000; i++) { double x = gen.sample().norm(2) / Math.sqrt(10); s.add(x); } assertEquals(0.1, s.getMean(), 0.01); }
@Override public Vector sample() { Vector v = new DenseVector(dimension).assign( new DoubleFunction() { @Override public double apply(double ignored) { return gen.nextGaussian(); } } ); if (mean != null) { if (scale != null) { return scale.times(v).plus(mean); } else { return v.plus(mean); } } else { if (scale != null) { return scale.times(v); } else { return v; } } }
MultiNormal implements Sampler<Vector> { @Override public Vector sample() { Vector v = new DenseVector(dimension).assign( new DoubleFunction() { @Override public double apply(double ignored) { return gen.nextGaussian(); } } ); if (mean != null) { if (scale != null) { return scale.times(v).plus(mean); } else { return v.plus(mean); } } else { if (scale != null) { return scale.times(v); } else { return v; } } } }
MultiNormal implements Sampler<Vector> { @Override public Vector sample() { Vector v = new DenseVector(dimension).assign( new DoubleFunction() { @Override public double apply(double ignored) { return gen.nextGaussian(); } } ); if (mean != null) { if (scale != null) { return scale.times(v).plus(mean); } else { return v.plus(mean); } } else { if (scale != null) { return scale.times(v); } else { return v; } } } MultiNormal(Vector diagonal);  MultiNormal(Vector diagonal, Vector mean);  MultiNormal(Matrix a, Vector mean);  MultiNormal(int dimension);  MultiNormal(double radius, Vector mean); private  MultiNormal(Matrix scale, Vector mean, int dimension); }
MultiNormal implements Sampler<Vector> { @Override public Vector sample() { Vector v = new DenseVector(dimension).assign( new DoubleFunction() { @Override public double apply(double ignored) { return gen.nextGaussian(); } } ); if (mean != null) { if (scale != null) { return scale.times(v).plus(mean); } else { return v.plus(mean); } } else { if (scale != null) { return scale.times(v); } else { return v; } } } MultiNormal(Vector diagonal);  MultiNormal(Vector diagonal, Vector mean);  MultiNormal(Matrix a, Vector mean);  MultiNormal(int dimension);  MultiNormal(double radius, Vector mean); private  MultiNormal(Matrix scale, Vector mean, int dimension); @Override Vector sample(); Vector getScale(); }
MultiNormal implements Sampler<Vector> { @Override public Vector sample() { Vector v = new DenseVector(dimension).assign( new DoubleFunction() { @Override public double apply(double ignored) { return gen.nextGaussian(); } } ); if (mean != null) { if (scale != null) { return scale.times(v).plus(mean); } else { return v.plus(mean); } } else { if (scale != null) { return scale.times(v); } else { return v; } } } MultiNormal(Vector diagonal);  MultiNormal(Vector diagonal, Vector mean);  MultiNormal(Matrix a, Vector mean);  MultiNormal(int dimension);  MultiNormal(double radius, Vector mean); private  MultiNormal(Matrix scale, Vector mean, int dimension); @Override Vector sample(); Vector getScale();  }