I'm conducting some research where I need the critical values of the one-sample Kolmogorov-Smirnov distribution. I've found a number of tables online, but the answers from these tables seem too high. Here's one example; all the tables I find online agree with this one: https://www.soest.hawaii.edu/GG/FACULTY/ITO/GG413/K_S_Table_one_Sample.pdf

I wrote my own code in R to try and verify these values through simulation. The code is shown below:

ks_sim_crit <- function(n, alpha = .05, num_sims = 1000000) {

  ks_stat_vec <- numeric(num_sims)
  for(iter in seq(from = 1, to = num_sims, by = 1)) {

    iter_points <- runif(n = n)
    iter_ecdf <- ecdf(iter_points)
    ks_stat <- max(abs(iter_ecdf(iter_points) - iter_points))
    ks_stat_vec[iter] <- ks_stat


  ks_stat_vec <- sort(ks_stat_vec)
  crit_val_index = round((1 - alpha) * num_sims)


When I run this code with n = 10 and the other default parameters I get a value of .377, where the table that I linked to suggests that the answer should be .409. Is there an error in my code or in the table?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.