From d325e038ba852006abab423a9876877991395f21 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 27 Sep 2020 20:43:11 +0200 Subject: [PATCH] Added test for the default parameters of distributions --- FastRngTests/Double/Distributions/Beta.cs | 17 ++++++++++ .../Double/Distributions/CauchyLorentz.cs | 17 ++++++++++ .../Double/Distributions/ChiSquare.cs | 17 ++++++++++ .../Double/Distributions/Exponential.cs | 15 +++++++++ FastRngTests/Double/Distributions/Gamma.cs | 17 ++++++++++ .../Double/Distributions/InverseGamma.cs | 17 ++++++++++ FastRngTests/Double/Distributions/Laplace.cs | 17 ++++++++++ .../Double/Distributions/LogNormal.cs | 17 ++++++++++ FastRngTests/Double/Distributions/Normal.cs | 17 ++++++++++ FastRngTests/Double/Distributions/StudentT.cs | 17 ++++++++++ FastRngTests/Double/Distributions/Uniform.cs | 32 +++++++++++++++++++ FastRngTests/Double/Distributions/Weibull.cs | 17 ++++++++++ 12 files changed, 217 insertions(+) diff --git a/FastRngTests/Double/Distributions/Beta.cs b/FastRngTests/Double/Distributions/Beta.cs index e7f4636..40db500 100644 --- a/FastRngTests/Double/Distributions/Beta.cs +++ b/FastRngTests/Double/Distributions/Beta.cs @@ -65,6 +65,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestBetaGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.Beta { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/CauchyLorentz.cs b/FastRngTests/Double/Distributions/CauchyLorentz.cs index 4952576..9fbcc09 100644 --- a/FastRngTests/Double/Distributions/CauchyLorentz.cs +++ b/FastRngTests/Double/Distributions/CauchyLorentz.cs @@ -45,6 +45,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestCauchyGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.CauchyLorentz { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/ChiSquare.cs b/FastRngTests/Double/Distributions/ChiSquare.cs index d5a4c9b..5e44bdd 100644 --- a/FastRngTests/Double/Distributions/ChiSquare.cs +++ b/FastRngTests/Double/Distributions/ChiSquare.cs @@ -63,6 +63,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestChiSquareGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.ChiSquare { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/Exponential.cs b/FastRngTests/Double/Distributions/Exponential.cs index 872edc5..2ac94ef 100644 --- a/FastRngTests/Double/Distributions/Exponential.cs +++ b/FastRngTests/Double/Distributions/Exponential.cs @@ -63,6 +63,21 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + [Test] [Category(TestCategories.COVER)] [Category(TestCategories.NORMAL)] + public async Task TestExponentialGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.Exponential { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } + [Test] [Category(TestCategories.COVER)] [Category(TestCategories.NORMAL)] diff --git a/FastRngTests/Double/Distributions/Gamma.cs b/FastRngTests/Double/Distributions/Gamma.cs index 40e2563..1736ce8 100644 --- a/FastRngTests/Double/Distributions/Gamma.cs +++ b/FastRngTests/Double/Distributions/Gamma.cs @@ -62,6 +62,23 @@ namespace FastRngTests.Double.Distributions Assert.That(stats.Variance, Is.EqualTo(VARIANCE).Within(0.1), "Variance is out of range"); } + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestGammaGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.Gamma { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } + [Test] [Category(TestCategories.COVER)] [Category(TestCategories.NORMAL)] diff --git a/FastRngTests/Double/Distributions/InverseGamma.cs b/FastRngTests/Double/Distributions/InverseGamma.cs index 45956bf..d7d9e19 100644 --- a/FastRngTests/Double/Distributions/InverseGamma.cs +++ b/FastRngTests/Double/Distributions/InverseGamma.cs @@ -64,6 +64,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestInverseGammaGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.InverseGamma { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/Laplace.cs b/FastRngTests/Double/Distributions/Laplace.cs index 462ea80..bdd5270 100644 --- a/FastRngTests/Double/Distributions/Laplace.cs +++ b/FastRngTests/Double/Distributions/Laplace.cs @@ -63,6 +63,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestLaplaceGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.Laplace { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/LogNormal.cs b/FastRngTests/Double/Distributions/LogNormal.cs index dc500fb..0187739 100644 --- a/FastRngTests/Double/Distributions/LogNormal.cs +++ b/FastRngTests/Double/Distributions/LogNormal.cs @@ -64,6 +64,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestLogNormalGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.LogNormal { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/Normal.cs b/FastRngTests/Double/Distributions/Normal.cs index 097a197..cb5a310 100644 --- a/FastRngTests/Double/Distributions/Normal.cs +++ b/FastRngTests/Double/Distributions/Normal.cs @@ -62,6 +62,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestNormalGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.Normal { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/StudentT.cs b/FastRngTests/Double/Distributions/StudentT.cs index 2c38ab9..ef7ad16 100644 --- a/FastRngTests/Double/Distributions/StudentT.cs +++ b/FastRngTests/Double/Distributions/StudentT.cs @@ -63,6 +63,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestStudentTGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.StudentT { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)] diff --git a/FastRngTests/Double/Distributions/Uniform.cs b/FastRngTests/Double/Distributions/Uniform.cs index 96bb560..ed7f51e 100644 --- a/FastRngTests/Double/Distributions/Uniform.cs +++ b/FastRngTests/Double/Distributions/Uniform.cs @@ -134,6 +134,38 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestUniformGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.Uniform { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestUniformGeneratorWithRange04() + { + var rng = new MultiThreadedRng(); + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await rng.GetUniform(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } + [Test] [Category(TestCategories.COVER)] [Category(TestCategories.NORMAL)] diff --git a/FastRngTests/Double/Distributions/Weibull.cs b/FastRngTests/Double/Distributions/Weibull.cs index cf96089..c02d764 100644 --- a/FastRngTests/Double/Distributions/Weibull.cs +++ b/FastRngTests/Double/Distributions/Weibull.cs @@ -64,6 +64,23 @@ namespace FastRngTests.Double.Distributions Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); } + + [Test] + [Category(TestCategories.COVER)] + [Category(TestCategories.NORMAL)] + public async Task TestWeibullGeneratorWithRange03() + { + var rng = new MultiThreadedRng(); + var dist = new FastRng.Double.Distributions.Weibull { Random = rng }; // Test default parameters + + var samples = new double[1_000]; + for (var n = 0; n < samples.Length; n++) + samples[n] = await dist.GetDistributedValue(); + + rng.StopProducer(); + Assert.That(samples.Min(), Is.GreaterThanOrEqualTo(0.0), "Min is out of range"); + Assert.That(samples.Max(), Is.LessThanOrEqualTo(1.0), "Max is out of range"); + } [Test] [Category(TestCategories.COVER)]