public void TestNanParameter() { var engine = MersenneTwister32Bit19937.InitGenRand(1); TestInvalidThrows <ArgumentException>(engine, double.NaN, 1d); TestInvalidThrows <ArgumentException>(engine, 1d, double.NaN); }
public void InitGenRandTest(uint seed) { // the number of random numbers to test // This is chosen so that the state is cycled twice. const int size = 1400; var generator = MersenneTwister32Bit19937.InitGenRand(seed); Assert.AreEqual( OriginalInitGenRand(seed, size), GetRandomValues(generator, size)); }
public void TestConstructValid() { var covarianceMatrix = new[, ] { { 1.0, 0.5 }, { 0.5, 1.0 }, }; var mean = new[] { 0.0, 0.0 }; var engine = MersenneTwister32Bit19937.InitGenRand(1); Assert.DoesNotThrow(() => _ = new MultivariateNormalSampler.Builder(mean, covarianceMatrix).Build(engine)); }
public void TestLength() { var mean = new[] { 0d, 0d }; var sigma = new[, ] { { 1d, 0.5 }, { 0.5, 1d }, }; var engine = MersenneTwister32Bit19937.InitGenRand(1); var sampler = new MultivariateNormalSampler.Builder(mean, sigma).Build(engine); Assert.AreEqual(2, sampler.Length); }