Accord.Tests.Statistics.KolmogorovSmirnovTestTest.KolmogorovSmirnovTestConstructorTest2 C# (CSharp) Method

KolmogorovSmirnovTestConstructorTest2() private method

private KolmogorovSmirnovTestConstructorTest2 ( ) : void
return void
        public void KolmogorovSmirnovTestConstructorTest2()
        {
            // Test against a Normal distribution

            // This time, let's see if the same sample from the previous example
            // could have originated from a standard Normal (Gaussian) distribution.
            //
            double[] sample =
            { 
                0.621, 0.503, 0.203, 0.477, 0.710, 0.581, 0.329, 0.480, 0.554, 0.382
            };

            // Before we could not rule out the possibility that the sample came from
            // a uniform distribution, which means the sample was not very far from
            // uniform. This would be an indicative that it would be far from what
            // would be expected from a Normal distribution:

            NormalDistribution distribution = NormalDistribution.Standard;

            var kstest = new KolmogorovSmirnovTest(sample, distribution);

            double statistic = kstest.Statistic; // 0.580432
            double pvalue = kstest.PValue; // 0.000999

            bool significant = kstest.Significant; // true

            // Since the test says that the null hypothesis should be rejected, then
            // this can be regarded as a strong indicative that the sample does not
            // comes from a Normal distribution, just as we expected.


            Assert.AreEqual(distribution, kstest.TheoreticalDistribution);
            Assert.AreEqual(KolmogorovSmirnovTestHypothesis.SampleIsDifferent, kstest.Hypothesis);
            Assert.AreEqual(DistributionTail.TwoTail, kstest.Tail);

            Assert.AreEqual(0.580432, kstest.Statistic, 1e-5);
            Assert.AreEqual(0.000999, kstest.PValue, 1e-5);
            Assert.IsFalse(Double.IsNaN(kstest.Statistic));

            // The null hypothesis can be rejected:
            // the sample is not from a standard Normal distribution
            Assert.IsTrue(kstest.Significant);
        }