Indeed, tks Wayne...appreciated.
Test-stat for Kolmogorov-Smirnov test
9 views (last 30 days)
Show older comments
Dear Sir or Madam, I am trying to apply the two-sample Kolmogorov-Smirnov test implemented in Matlab (ktest2), but the description of the test statistic (ks2stat) used (as shown in the current documentation) is not clear enough. How is the test statistic calculated? The documentation provides some references but does not clearly specify what the ktest2 formula is really using as test stat. Could provide some more clarity on that? Tks!
0 Comments
Accepted Answer
More Answers (3)
Wayne King
on 26 Sep 2013
Edited: Wayne King
on 26 Sep 2013
The two-sided test as implemented is essentially described here:
The two-sided test computes the empirical CDFs of the two data samples and computes the statistic
T = max|F1(x) - F2(x)| where F1(x) is the empirical CDF of one sample and F2(x) is the empirical CDF of the other.
The p-value is computed from the result described on the above link in the "Kolmogorov distribution" section.
You can see that in MATLAB code here:
j = (1:101)';
pValue = 2 * sum((-1).^(j-1).*exp(-2*lambda*lambda*j.^2));
pValue = min(max(pValue, 0), 1);
The one-sided cases are a bit different, are you interested in the one-sided or two-sided case?
See Also
Categories
Find more on Hypothesis Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!