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

KolmogorovSmirnovTestConstructorTest() private method

private KolmogorovSmirnovTestConstructorTest ( ) : void
return void
        public void KolmogorovSmirnovTestConstructorTest()
        {
            // Test against a standard Uniform distribution
            // References: http://www.math.nsysu.edu.tw/~lomn/homepage/class/92/kstest/kolmogorov.pdf


            // Suppose we got a new sample, and we would like to test whether this
            // sample seems to have originated from a uniform continuous distribution.
            //
            double[] sample = 
            { 
                0.621, 0.503, 0.203, 0.477, 0.710, 0.581, 0.329, 0.480, 0.554, 0.382
            };

            // First, we create the distribution we would like to test against:
            //
            var distribution = UniformContinuousDistribution.Standard;

            // Now we can define our hypothesis. The null hypothesis is that the sample
            // comes from a standard uniform distribution, while the alternate is that
            // the sample is not from a standard uniform distribution.
            //
            var kstest = new KolmogorovSmirnovTest(sample, distribution);

            double statistic = kstest.Statistic; // 0.29
            double pvalue = kstest.PValue; // 0.3067

            bool significant = kstest.Significant; // false

            // Since the null hypothesis could not be rejected, then the sample
            // can perhaps be from a uniform distribution. However, please note
            // that this doesn't means that the sample *is* from the uniform, it
            // only means that we could not rule out the possibility.

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

            Assert.AreEqual(0.29, statistic, 1e-16);
            Assert.AreEqual(0.3067, pvalue, 1e-4);
            Assert.IsFalse(Double.IsNaN(pvalue));

            
            Assert.IsFalse(kstest.Significant);
        }