faithful <- read.delim("faithful.txt") attributes(faithful) dim(faithful)[1] ss.size<-dim(faithful )[1] my.sample <- faithful$eruptions $OR e.g. ss.size<-100 my.sample <- rnorm(ss.size) Fn.hat<-ecdf(my.sample) Fn.hat(0) knots(Fn.hat) plot(Fn.hat,verticals=TRUE,do.points=TRUE) rug(my.sample,add=TRUE) x.grid <- seq(-3, 3, length = 500) lines(x.grid, pnorm(x.grid), col = "blue") #ls(environment(Fn.hat)) xx <- get("x", envir=environment(Fn.hat))# = sort(x) yy <- get("y", envir=environment(Fn.hat)) D <- 1.36/(ss.size^(1/2)) yyu <- pmin(yy+D, 1) yyl <- pmax(yy-D, 0) ecu <- stepfun(xx, c(D,yyu),right=FALSE ) ecl <- stepfun(xx, c(0,yyl),right=FALSE ) plot(ecu, add=TRUE, verticals=TRUE, do.points=FALSE, col.hor="red" , col.vert="red",lty=2) plot(ecl, add=TRUE, verticals=TRUE, do.points=FALSE, col.hor="red", col.vert="red",lty=2) ks.test(my.sample,"pnorm",0,1) my.pnorm <- function(point) { my.pnorm <- pnorm(point) } ks.test(my.sample,"pnorm",0,1) ks.test(my.sample,"my.pnorm" )