Example

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.
import com.imsl.stat.*;

public class KolmogorovTwoSampleEx1 {

    static public void main(String arg[]) {
        
        double x[] = new double[100];
        double y[] = new double[60];
        Random random = new Random(123457);
        random.setMultiplier(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);
        System.out.println("D  = "+ k2s.getTestStatistic());
        System.out.println("D+ = " + k2s.getMaximumDifference());
        System.out.println("D- = " + k2s.getMinimumDifference());
        System.out.println("Z   = " + k2s.getZ());
        System.out.println("Prob greater D one sided = " +
                k2s.getOneSidedPValue());
        System.out.println("Prob greater D two sided = " +
                k2s.getTwoSidedPValue());
        System.out.println("Missing X = " + k2s.getNumberMissingX());
        System.out.println("Missing Y = " + k2s.getNumberMissingY());
    }
}

Output

D  = 0.18
D+ = 0.18
D- = 0.010000000000000009
Z   = 1.1022703842524302
Prob greater D one sided = 0.07201060734868497
Prob greater D two sided = 0.14402121469736995
Missing X = 0
Missing Y = 0
Link to Java source.