Example: Kolmogorov Two Sample

The following example illustrates the class KolmogorovTwoSample routine with two randomly generated samples from a uniform(0,1) distribution. Since the two theoretical distributions are identical, we would not expect to reject the null hypothesis.
using System;
using Imsl.Stat;
using Imsl.Math;

public class KolmogorovTwoSampleEx1
{
	public static void Main(String[] args)
	{        
        double[] x = new double[100];
		double[] y = new double[60];
        Imsl.Stat.Random random = new Imsl.Stat.Random(123457);
        random.Multiplier = 16807;
		for (int i = 0;  i < x.Length;  i++) 
		{
			x[i] = random.NextFloat();
		}
		for (int i = 0;  i < y.Length;  i++) 
		{
            y[i] = random.NextFloat();
        }
        
        KolmogorovTwoSample k2s = new KolmogorovTwoSample(x, y);
        Console.WriteLine("D  = "+ k2s.TestStatistic);
        Console.WriteLine("D+ = " + k2s.MaximumDifference);
        Console.WriteLine("D- = " + k2s.MinimumDifference);
        Console.WriteLine("Z   = " + k2s.Z);
        Console.WriteLine("Prob greater D one sided = " +
                k2s.OneSidedPValue);
        Console.WriteLine("Prob greater D two sided = " +
                k2s.TwoSidedPValue);
        Console.WriteLine("Missing X = " + k2s.NumberMissingX);
		Console.WriteLine("Missing Y = " + k2s.NumberMissingY);
	}
}

Output

D  = 0.18
D+ = 0.18
D- = 0.01
Z   = 1.10227038425243
Prob greater D one sided = 0.072010607348685
Prob greater D two sided = 0.14402121469737
Missing X = 0
Missing Y = 0

Link to C# source.