/// <summary> /// Initializes a new instance of the <see cref="MultivariateNormalSampler"/> class. /// </summary> /// <param name="engine"> /// The simulation engine to be used for sampling. /// </param> /// <param name="mean"> /// The mean values of the variables to be generated simultaneously. /// </param> /// <param name="choleskyFactor"> /// The Cholesky factorization of a matrix defining the desired joint distribution. /// </param> private MultivariateNormalSampler(IRandomNumberEngine engine, double[] mean, double[] choleskyFactor) { this.Length = mean.Length; this.mean = mean; this.choleskyFactor = choleskyFactor; this.standardNormalSampler = new StandardNormalSampler(engine); this.buffer = new double[this.mean.Length]; }
public void TestFill() { var sampler1 = new StandardNormalSampler(new ReducedThreeFry4X64(1)); var actual = Enumerable.Repeat(sampler1, 10).Select(x => x.GetNext()).ToArray(); var sampler2 = new StandardNormalSampler(new ReducedThreeFry4X64(1)); var expected = new double[10]; sampler2.Fill(expected); Assert.AreEqual(expected, actual); }
public void TestConstructInvalid() { Assert.Throws <ArgumentNullException>( () => _ = new StandardNormalSampler(null)); }