n<-10
x<-rnorm(n)
Fn<-ecdf(x)
class(Fn)
plot(Fn, do.points=F)
v<-seq(-3,4,by=0.01)
Fv<-pnorm(v)
lines(Fv~v, col="red")
Fn(0)



y<-rchisq(100,2)
Fny<-ecdf(y)
class(Fny)
plot(Fny, do.points=F)
w<-seq(-1,9,by=0.01)
Fw<-pchisq(w,df=2)
lines(Fw~w, col="red")
Fn(0)
#################
n<-100
alfa=0.05
x<-rnorm(n)
eps=sqrt(1/(2*n)*log(2/alfa))

Fn<-ecdf(x)
plot(Fn, do.points=F)
t<-seq(-3,4,by=0.01)
L<-pmax(Fn(t)-eps,0)
U<-pmin(Fn(t)+eps,1)

points(t,U,type="s")
points(t,L,type="s")
lines(pnorm(t)~t,col="red")

############################

L2<-pmax(Fn(t)-qnorm(1-alfa/2)*sqrt(Fn(t)*(1-Fn(t))/n),0)
U2<-pmin(Fn(t)+qnorm(1-alfa/2)*sqrt(Fn(t)*(1-Fn(t))/n),1)
points(t,L2,type="s",col=4)
points(t,U2,type="s",col=4)


#######################################
L3<-pmax(Fn(t)-qnorm(1-alfa/2)*sqrt(pnorm(t)*(1-pnorm(t))/n),0)
U3<-pmin(Fn(t)+qnorm(1-alfa/2)*sqrt(pnorm(t)*(1-pnorm(t))/n),1)
points(t,L3,type="s",col=6)
points(t,U3,type="s",col=6)



