コード例 #1
0
        public async Task TestLogNormalDistribution01()
        {
            using var rng = new MultiThreadedRng();
            var dist = new FastRng.Double.Distributions.LogNormalS1M0(rng);
            var fra  = new FrequencyAnalysis();

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

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

            Assert.That(result[0], Is.EqualTo(0.001505531).Within(0.003));
            Assert.That(result[1], Is.EqualTo(0.014408709).Within(0.01));
            Assert.That(result[2], Is.EqualTo(0.043222256).Within(0.02));

            Assert.That(result[21], Is.EqualTo(0.876212056).Within(0.15));
            Assert.That(result[22], Is.EqualTo(0.895582226).Within(0.15));
            Assert.That(result[23], Is.EqualTo(0.912837250).Within(0.15));

            Assert.That(result[50], Is.EqualTo(0.948062005).Within(0.2));

            Assert.That(result[75], Is.EqualTo(0.768584762).Within(0.089));
            Assert.That(result[85], Is.EqualTo(0.697303612).Within(0.089));
            Assert.That(result[90], Is.EqualTo(0.663570581).Within(0.089));

            Assert.That(result[97], Is.EqualTo(0.618792767).Within(0.089));
            Assert.That(result[98], Is.EqualTo(0.612636410).Within(0.089));
            Assert.That(result[99], Is.EqualTo(0.606540679).Within(0.089));
        }
コード例 #2
0
 public async Task TestLogNormalGeneratorWithRange01()
 {
     using var rng = new MultiThreadedRng();
     var dist    = new FastRng.Double.Distributions.LogNormalS1M0(rng);
     var samples = new double[1_000];