
Hey,
A simple question, I am trying to do a two sample KS test to test if a sample is drawn from a given distribution but I am not sure how I can convert my first sample into a distribution...??
Eg,
public TestResult KolmogorovSmirnovTest(
Distribution distribution
)
I can .Add numbers to my sample, but I am not sure what to do with the Distribution..??



To do a twosample KS test, use the overload that takes a Sample instead of a distribution, e.g. TestResult result = sample1.KolmogorovSmirnovTest(sample2). The overload that takes a distribution is for doing a onesample KS test of a sample against known
distribution.



Excellent..!
It works perfectly, with one exception.....
It seems to be using the asymptotic distributions instead of an exact pvalue.
The code seems to suggest it is easy to implement the exact pvalue but I am not sure where to start. Any hints...?
Thanks



You are correct. I'm sorry if the release notes misled you here: we have implemented the exact null distributions for the onesample KS and Kuiper tests, but not (yet) for the twosample versions of those tests.
While they share the same largeN asymptotic distribution, the finiteN distributions in the onesample and twosample cases are actually quite different beasts. In fact, the onesample distribution is continuous and the twosample distribution is discrete
(because in the twosample case D will always be an integer multiple of 1/nm). So the bad news is that you can't simply reuse or modify the existing code for the finiteN onesample distribution to get a finiteN twosample distribution. The good news is
that the work required to code up the finiteN twosample distribution appears to be considerably less than what was required for the onesample distribution, so you can be reasonably confident that the exact twosample distribution will get in to the next
release.
Until then, it looks like R is the only common statistics framework with an exact twosample KS null distribution. (SPSS doesn't appear to have it.) You could also take a look at the original reference and consider coding it up yourself: Kim & Jenrich,
"Tables of Exact Sampling Distribution of the TwoSample KolmogorovSmirnov Criterion", in Selected Tables of Mathematical Statistics Vol. I (1973) pp. 80129.

