コード例 #1
0
ファイル: DistributionTest.cs プロジェクト: sergioariza/PFC
        public void TestDistributionShapeTestHelper()
        {
            DistributionShape shape = DistributionShape.CreateMinMax(2, -1.0, +1.0);

            shape.Push(-1.5); // underflow
            shape.Push(-1.0); // 0
            shape.Push(-0.5); // 0
            shape.Push(0.0);  // 1
            shape.Push(0.5);  // 1
            shape.Push(1.0);  // overflow
            shape.Push(1.5);  // overflow

            Assert.AreEqual(1, shape.Underflow, "underflow");
            Assert.AreEqual(2, shape.Overflow, "overflow");
            Assert.AreEqual(2, shape[0], "0");
            Assert.AreEqual(2, shape[1], "1");
        }
コード例 #2
0
ファイル: DistributionTest.cs プロジェクト: sergioariza/PFC
        private void TestContinuousDistributionShape(
            ContinuousDistribution distribution,
            double min, double max,
            double[] expectedShape, double expectedUnderflow, double expectedOverflow,
            int avgSamplesPerBucket, double absoluteAccuracy, string message)
        {
            DistributionShape shape = DistributionShape.CreateMinMax(expectedShape.Length, min, max);
            int sampleCount         = expectedShape.Length * avgSamplesPerBucket;

            for (int i = 0; i < sampleCount; i++)
            {
                shape.Push(distribution.NextDouble());
            }
            double scale = 1.0 / (avgSamplesPerBucket * expectedShape.Length);

            Assert.AreEqual(expectedUnderflow, shape.Underflow * scale, absoluteAccuracy, message + " Underflow");
            Assert.AreEqual(expectedOverflow, shape.Overflow * scale, absoluteAccuracy, message + " Overflow");
            for (int i = 0; i < expectedShape.Length; i++)
            {
                Assert.AreEqual(expectedShape[i], shape[i] * scale, absoluteAccuracy, message + " Bucket " + i.ToString());
            }
        }