Accord.Tests.Statistics.ZTestTest.PValueToStatisticTest C# (CSharp) Méthode

PValueToStatisticTest() private méthode

private PValueToStatisticTest ( ) : void
Résultat void
        public void PValueToStatisticTest()
        {
            double p = 0.05;
            double z = 0;
            {
                ZTest target = new ZTest(z, OneSampleHypothesis.ValueIsDifferentFromHypothesis);
                Assert.AreEqual(DistributionTail.TwoTail, target.Tail);
                double actual = target.PValueToStatistic(p);
                double expected = 1.96;
                Assert.AreEqual(expected, actual, 0.01);
            }

            {
                ZTest target = new ZTest(z, OneSampleHypothesis.ValueIsSmallerThanHypothesis);
                Assert.AreEqual(DistributionTail.OneLower, target.Tail);
                double actual = target.PValueToStatistic(p);
                double expected = -1.6449;
                Assert.AreEqual(expected, actual, 1e-4);
            }

            {
                ZTest target = new ZTest(z, OneSampleHypothesis.ValueIsGreaterThanHypothesis);
                Assert.AreEqual(DistributionTail.OneUpper, target.Tail);
                double actual = target.PValueToStatistic(p);
                double expected = 1.6449;
                Assert.AreEqual(expected, actual, 1e-4);
            }

            p = 0.95;
            {
                ZTest target = new ZTest(z, OneSampleHypothesis.ValueIsDifferentFromHypothesis);
                Assert.AreEqual(DistributionTail.TwoTail, target.Tail);
                double actual = target.PValueToStatistic(p);
                double expected = 0.0627;
                Assert.AreEqual(expected, actual, 1e-5);
            }

            {
                ZTest target = new ZTest(z, OneSampleHypothesis.ValueIsSmallerThanHypothesis);
                Assert.AreEqual(DistributionTail.OneLower, target.Tail);
                double actual = target.PValueToStatistic(p);
                double expected = 1.6449;
                Assert.AreEqual(expected, actual, 1e-4);
            }

            {
                ZTest target = new ZTest(z, OneSampleHypothesis.ValueIsGreaterThanHypothesis);
                Assert.AreEqual(DistributionTail.OneUpper, target.Tail);
                double actual = target.PValueToStatistic(p);
                double expected = -1.6449;
                Assert.AreEqual(expected, actual, 1e-4);
            }
        }