Esempio n. 1
0
        public async Task TestExponentialDistribution01()
        {
            using var rng = new MultiThreadedRng();
            var dist = new FastRng.Float.Distributions.ExponentialLa10(rng);
            var fqa  = new FrequencyAnalysis();

            for (var n = 0; n < 100_000; n++)
            {
                fqa.CountThis(await dist.NextNumber());
            }

            var result = fqa.NormalizeAndPlotEvents(TestContext.WriteLine);

            Assert.That(result[0], Is.EqualTo(1.00075018434777f).Within(0.05f));
            Assert.That(result[1], Is.EqualTo(0.905516212904248f).Within(0.05f));
            Assert.That(result[2], Is.EqualTo(0.81934495207398f).Within(0.05f));

            Assert.That(result[21], Is.EqualTo(0.122548293148741f).Within(0.12f));
            Assert.That(result[22], Is.EqualTo(0.110886281157421f).Within(0.12f));
            Assert.That(result[23], Is.EqualTo(0.10033405633809f).Within(0.12f));

            Assert.That(result[50], Is.EqualTo(0.00674300170146f).Within(0.005f));

            Assert.That(result[75], Is.EqualTo(0.000553499285385f).Within(0.001f));
            Assert.That(result[85], Is.EqualTo(0.000203621007796f).Within(0.001f));
            Assert.That(result[90], Is.EqualTo(0.00012350238419f).Within(0.001f));

            Assert.That(result[97], Is.EqualTo(0.0000613294689720f).Within(0.0008f));
            Assert.That(result[98], Is.EqualTo(0.0000554931983541f).Within(0.0008f));
            Assert.That(result[99], Is.EqualTo(0.0000502123223173f).Within(0.0008f));
        }
Esempio n. 2
0
 public async Task TestExponentialGeneratorWithRange01()
 {
     using var rng = new MultiThreadedRng();
     var dist    = new FastRng.Float.Distributions.ExponentialLa10(rng);
     var samples = new float[1_000];