Function Reference: kstest2

statistics: h = kstest2 (x1, x2)
statistics: h = kstest2 (x1, x2, name, value)
statistics: [h, p] = kstest2 (…)
statistics: [h, p, ks2stat] = kstest2 (…)

Two-sample Kolmogorov-Smirnov goodness-of-fit hypothesis test.

h = kstest2 (x1, x2) returns a test decision for the null hypothesis that the data in vectors x1 and x2 are from the same continuous distribution, using the two-sample Kolmogorov-Smirnov test. The alternative hypothesis is that x1 and x2 are from different continuous distributions. The result h is 1 if the test rejects the null hypothesis at the 5% significance level, and 0 otherwise.

h = kstest2 (x1, x2, name, value) returns a test decision for a two-sample Kolmogorov-Smirnov test with additional options specified by one or more name-value pair arguments as shown below.

"alpha"A value alpha between 0 and 1 specifying the significance level. Default is 0.05 for 5% significance.
"tail"A string indicating the type of test:
"unequal""F(X1) not equal to F(X2)" (two-sided) [Default]
"larger""F(X1) > F(X2)" (one-sided)
"smaller""F(X1) < F(X2)" (one-sided)

The two-sided test uses the maximum absolute difference between the cdfs of the distributions of the two data vectors. The test statistic is D* = max(|F1(x) - F2(x)|), where F1(x) is the proportion of x1 values less or equal to x and F2(x) is the proportion of x2 values less than or equal to x. The one-sided test uses the actual value of the difference between the cdfs of the distributions of the two data vectors rather than the absolute value. The test statistic is D* = max(F1(x) - F2(x)) or D* = max(F2(x) - F1(x)) for tail = "larger" or "smaller", respectively.

[h, p] = kstest2 (…) also returns the asymptotic p-value p.

[h, p, ks2stat] = kstest2 (…) also returns the Kolmogorov-Smirnov test statistic ks2stat defined above for the test type indicated by tail.

See also: kstest, cdfplot

Source Code: kstest2