Example: Kolmogorov One Sample

In this example, a random sample of size 100 is generated using class Random for the uniform (0, 1) distribution. We want to test the null hypothesis that the cdf is the standard normal distribution with a mean of 0.5 and a variance equal to the uniform (0, 1) variance (1/12).
using System;
using Imsl.Stat;
using Imsl.Math;


public class KolmogorovOneSampleEx1 : ICdfFunction
{
    public static void Main(String[] args)
    {        
        double[] x = new double[100];
        Imsl.Stat.Random random = new Imsl.Stat.Random(123457);
        random.Multiplier = 16807;
        for (int i = 0;  i < x.Length;  i++) {
            x[i] = random.NextDouble();
        }
        
        ICdfFunction cdf = new KolmogorovOneSampleEx1();
        KolmogorovOneSample kos = new KolmogorovOneSample(cdf, x);
        Console.WriteLine("D  = "+ kos.TestStatistic);
        Console.WriteLine("D+ = " + kos.MaximumDifference);
        Console.WriteLine("D- = " + kos.MinimumDifference);
        Console.WriteLine("Z   = " + kos.Z);
        Console.WriteLine("Prob greater D one sided = " +
                kos.OneSidedPValue);
        Console.WriteLine("Prob greater D two sided = " +
                kos.TwoSidedPValue);
        Console.WriteLine("N missing = " + kos.NumberMissing);
    }

    public double CdfFunction(double x) 
    {
        double mean = 0.5;
        double std = 0.2886751;
        double z = (x - mean) / std;
        return Cdf.Normal(z);
    }
}

Output

D  = 0.121914080665685
D+ = 0.121914080665685
D- = 0.0869429640568776
Z   = 1.21914080665685
Prob greater D one sided = 0.0511696542584409
Prob greater D two sided = 0.102339308516882
N missing = 0

Link to C# source.