function (xx, N) { # xx must be a nonempty subset of 1:N m = length(xx) n=N-m yy=(1:N)[-xx] Z =1:N s = NULL for (j in 1:N) { s[j] = mean(xx<=Z[j])-mean(yy<=Z[j]) } KS.stat = max(abs(s)) KS.stat }