Kolmogorov-Smirov two sample test, ties -- will adding random noise fix the problem? There are a lot of questions on this site about warning for "ties" in the Kolmogorov-Smirnov test. Here are a few of those questions.
Is there an alternative to the Kolmogorov-Smirnov test for tied data with correction?
https://stackoverflow.com/questions/51987605/problems-with-ks-test-and-ties
"Ties should not be present" in one-sample Kolmgorov-Smirnov test in R
I understand that if there are repeated values in a test sample, then that will throw off the K-S test and generate the warning. However, I have not really seen any of these posts indicate a solution to the problem. Certainly removing repeated values will just change the distribution of the data, so that is not a particularly good solution.
I was thinking that I could just add some random noise to the data, to essentially "jitter" the data. So if I added random normal noise to each observation with mean = 0.0 and variance = 0.01, wouldn't that break the ties and let me perform the test without any problems. My sample size is pretty large, so this should cancel out any artifacts from the addition of noise.
I can run some simulations to try out my idea, but just wanted to see if anyone saw any obvious issues with this approach?
 A: Any time you find yourself having to 'inject noise' into your data, something has probably went wrong in the modelling process (most likely you are making an assumption that the distribution is continuous when its actually discrete).
If there are ties in your data then at least part of the generating distribution is discrete, and so a goodness-of-fit statistic which incorporates this should be chosen instead (eg a chi-square test), otherwise you can compute the p-value of the Kolmogorov-Smirnov test statistic yourself using a permutation test rather than relying on the default approximations which assume continuous data.
By the way, Kolmogorov-Smirnov isnt a great test since it only looks at a single point of the empirical distribution (its maximum). A better test which is usually more powerful is Cramer-von-Mises which instead looks at the average value. The Lepage test is also often a sensible choice. See https://www.tandfonline.com/doi/abs/10.1080/02664760220136212
As above, you should use a permutation test to get p-values for all of these statistics (assuming that you are doing a two-sample test), since the built-in p-values in R assume continuous data .
