public void Constructor() { var d = new UniformDistributionF(2, 3); Assert.AreEqual(2, d.MinValue); Assert.AreEqual(3, d.MaxValue); }
public void Test1() { UniformDistributionF d = new UniformDistributionF(); // Create 100 random values and check if they are valid. for (int i = 0; i < 100; i++) { float r = d.Next(RandomHelper.Random); Assert.IsTrue(-1 <= r); Assert.IsTrue(r <= 1); } Assert.AreEqual(-1, d.MinValue); Assert.AreEqual(1, d.MaxValue); d.MaxValue = 100; Assert.AreEqual(-1, d.MinValue); Assert.AreEqual(100, d.MaxValue); d.MinValue = 99.9f; Assert.AreEqual(99.9f, d.MinValue); Assert.AreEqual(100, d.MaxValue); for (int i = 0; i < 100; i++) { float r = d.Next(RandomHelper.Random); Assert.IsTrue(99.9f <= r); Assert.IsTrue(r <= 100); } }
public void Test1() { UniformDistributionF d = new UniformDistributionF(); // Create 100 random values and check if they are valid. for (int i=0; i<100; i++) { float r = d.Next(RandomHelper.Random); Assert.IsTrue(-1 <= r); Assert.IsTrue(r <= 1); } Assert.AreEqual(-1, d.MinValue); Assert.AreEqual(1, d.MaxValue); d.MaxValue = 100; Assert.AreEqual(-1, d.MinValue); Assert.AreEqual(100, d.MaxValue); d.MinValue = 99.9f; Assert.AreEqual(99.9f, d.MinValue); Assert.AreEqual(100, d.MaxValue); for (int i = 0; i < 100; i++) { float r = d.Next(RandomHelper.Random); Assert.IsTrue(99.9f <= r); Assert.IsTrue(r <= 100); } }
public void RandomFromDistribution() { Distribution<float> distribution = new ConstValueDistribution<float>(123.456f); float f = RandomHelper.Next(null, distribution); Assert.AreEqual(123.456f, f); var random = new Random(123456); distribution = new UniformDistributionF(1.0f, 2.0f); f = random.Next(distribution); Assert.IsTrue(1.0f <= f && f <= 2.0f); }
public void RandomFromDistribution() { Distribution <float> distribution = new ConstValueDistribution <float>(123.456f); float f = RandomHelper.Next(null, distribution); Assert.AreEqual(123.456f, f); var random = new Random(123456); distribution = new UniformDistributionF(1.0f, 2.0f); f = random.Next(distribution); Assert.IsTrue(1.0f <= f && f <= 2.0f); }