Accord.Tests.Statistics.TTestTest.TTestConstructorTest C# (CSharp) Method

TTestConstructorTest() private method

private TTestConstructorTest ( ) : void
return void
        public void TTestConstructorTest()
        {

            // mean = 0.5, var = 1
            double[] sample = 
            { 
                -0.849886940156521, 3.53492346633185,  1.22540422494611, 0.436945126810344, 1.21474290382610,
                 0.295033941700225, 0.375855651783688, 1.98969760778547, 1.90903448980048,  1.91719241342961
            };


            // Null Hypothesis: Values are equal
            // Alternative    : Values are different
            double hypothesizedMean = 0;
            OneSampleHypothesis hypothesis = OneSampleHypothesis.ValueIsDifferentFromHypothesis;
            TTest target = new TTest(sample, hypothesizedMean, hypothesis);

            Assert.AreEqual(3.1254485381338246, target.Statistic);
            Assert.AreEqual(OneSampleHypothesis.ValueIsDifferentFromHypothesis, target.Hypothesis);
            Assert.AreEqual(DistributionTail.TwoTail, target.Tail);
            Assert.AreEqual(0.012210924322697769, target.PValue);
            Assert.IsTrue(target.Significant);


            // Null hypothesis: value is smaller than hypothesis
            // Alternative    : value is greater than hypothesis

            // If the null hypothesis states that the population parameter is less
            // than zero (or a constant), the z-score that rejects the null is always
            // positive and greater than the score set for the rejection condition.
            hypothesis = OneSampleHypothesis.ValueIsGreaterThanHypothesis;
            target = new TTest(sample, hypothesizedMean, hypothesis);

            // z-score is positive:
            Assert.AreEqual(3.1254485381338246, target.Statistic);
            Assert.AreEqual(OneSampleHypothesis.ValueIsGreaterThanHypothesis, target.Hypothesis); // right tail
            Assert.AreEqual(DistributionTail.OneUpper, target.Tail); // right tail
            Assert.AreEqual(0.0061054621613488846, target.PValue);
            Assert.IsTrue(target.Significant); // null should be rejected

            // Null hypothesis: value is greater than hypothesis
            // Alternative:     value is smaller than hypothesis

            // If the null hypothesis states that the population parameter is 
            // greater than zero (or a constant), the z-score that rejects the
            // null is always negative and less than the score set for the 
            // rejection condition.
            hypothesis = OneSampleHypothesis.ValueIsSmallerThanHypothesis;
            target = new TTest(sample, hypothesizedMean, hypothesis);

            // z-score is positive:
            Assert.AreEqual(3.1254485381338246, target.Statistic);
            Assert.AreEqual(OneSampleHypothesis.ValueIsSmallerThanHypothesis, target.Hypothesis); // left tail
            Assert.AreEqual(DistributionTail.OneLower, target.Tail); // left tail
            Assert.AreEqual(0.99389453783865112, target.PValue);
            Assert.IsFalse(target.Significant); // null cannot be rejected
        }