R version 3.2.4 RC (2016-03-02 r70281) -- "Very Secure Dishes" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## some examples of the KS test > > ## unrealistic one of PR#14561 > ds1 <- c(1.7,2,3,3,4,4,5,5,6,6) > ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216) One-sample Kolmogorov-Smirnov test data: ds1 D = 0.274, p-value = 0.4407 alternative hypothesis: two-sided Warning message: In ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216) : ties should not be present for the Kolmogorov-Smirnov test > # how on earth can sigma = 1.55216 be known? > > # R >= 2.14.0 allows the equally invalid > ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216, exact = TRUE) One-sample Kolmogorov-Smirnov test data: ds1 D = 0.274, p-value = 0.3715 alternative hypothesis: two-sided Warning message: In ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216, exact = TRUE) : ties should not be present for the Kolmogorov-Smirnov test > > ## Try out the effects of rounding > set.seed(123) > ds2 <- rnorm(1000) > ks.test(ds2, "pnorm") # exact = FALSE is default for n = 1000 One-sample Kolmogorov-Smirnov test data: ds2 D = 0.019416, p-value = 0.8452 alternative hypothesis: two-sided > ks.test(ds2, "pnorm", exact = TRUE) One-sample Kolmogorov-Smirnov test data: ds2 D = 0.019416, p-value = 0.8379 alternative hypothesis: two-sided > ## next two are still close > ks.test(round(ds2, 2), "pnorm") One-sample Kolmogorov-Smirnov test data: round(ds2, 2) D = 0.019169, p-value = 0.856 alternative hypothesis: two-sided Warning message: In ks.test(round(ds2, 2), "pnorm") : ties should not be present for the Kolmogorov-Smirnov test > ks.test(round(ds2, 2), "pnorm", exact = TRUE) One-sample Kolmogorov-Smirnov test data: round(ds2, 2) D = 0.019169, p-value = 0.8489 alternative hypothesis: two-sided Warning message: In ks.test(round(ds2, 2), "pnorm", exact = TRUE) : ties should not be present for the Kolmogorov-Smirnov test > # now D has doubled, but p-values remain similar (if very different from ds2) > ks.test(round(ds2, 1), "pnorm") One-sample Kolmogorov-Smirnov test data: round(ds2, 1) D = 0.03674, p-value = 0.1344 alternative hypothesis: two-sided Warning message: In ks.test(round(ds2, 1), "pnorm") : ties should not be present for the Kolmogorov-Smirnov test > ks.test(round(ds2, 1), "pnorm", exact = TRUE) One-sample Kolmogorov-Smirnov test data: round(ds2, 1) D = 0.03674, p-value = 0.1311 alternative hypothesis: two-sided Warning message: In ks.test(round(ds2, 1), "pnorm", exact = TRUE) : ties should not be present for the Kolmogorov-Smirnov test > > > proc.time() user system elapsed 0.111 0.014 0.116