: [pval, ks, d] = kolmogorov_smirnov_test_2 (x, y, alt)

Perform a 2-sample Kolmogorov-Smirnov test of the null hypothesis that the samples x and y come from the same (continuous) distribution.

If F and G are the CDFs corresponding to the x and y samples, respectively, then the null is that F == G.

With the optional argument string alt, the alternative of interest can be selected. If alt is "!=" or "<>", the null is tested against the two-sided alternative F != G. In this case, the test statistic ks follows a two-sided Kolmogorov-Smirnov distribution. If alt is ">", the one-sided alternative F > G is considered. Similarly for "<", the one-sided alternative F < G is considered. In this case, the test statistic ks has a one-sided Kolmogorov-Smirnov distribution. The default is the two-sided case.

The p-value of the test is returned in pval.

The third returned value, d, is the test statistic, the maximum vertical distance between the two cumulative distribution functions.

If no output argument is given, the p-value is displayed.

Package: statistics