#The following code gives the estimated sampling # # distribution of the (corrected) mean in four ways. # # 1) Sampling from the actual distribution (xn) # # 2) Using the bootstrap distribution (xboot) # # 3) Using the uncorrected jackknife distribution (xi) # # 4) And using the jacknife distribution times sqrt (n) # #The par(mfrow=c(2,2)) line prints the graphics out in# # a square. # #Note that running this only a single time will only # # give you a noisy picture of whats happening. # par(mfrow=c(2,2)) xn<-rep(0,100) for (i in 1:100) {xn[i]<-mean(rnorm(20,3,5))} hist(xn-3,xlim=c(-5,5),breaks=(-5:5)) x<-rnorm(20,3,5) xboot<-rep(0,100) for (i in 1:100) {xboot[i]<-mean(sample(x,replace=T))} hist(xboot-mean(x),xlim=c(-5,5),breaks=(-5:5)) xi<-rep(0,length(x)) for (i in 1:length(x)) {xi[i]<-mean(x[-i])} hist(xi-mean(x),xlim=c(-5,5),breaks=(-10:10)/2) hist(sqrt(19)*(xi-mean(x)),xlim=c(-5,5),breaks=(-5:5))