# Contributor: Kotioni Christina
# email: ckotioni@windowslive.com
x<-rnorm(50,0,1) # sample of random numbers
iter<-500     # vector of sampling
n<-1000     # number of samples
ss<-c(1:iter) # vector of samples
ddd<-c(1:n)   # vector that stores the sd of each sample
sss<-c(1:n)   # vector that stores the mean of each sample
for(i in 1:n){z<-0
   while(z <iter+1) { 
     z <- z + 1
     ss[z]<- sample(x,1,replace=T)  #define sample
                   
 }
 sss[i]<-mean(ss)# define the mean of the bootstrap method
 ddd[i]<-sd(ss)# define the sd of the boostrap method
}
low<-mean(sss)-2*mean(ddd)
upper<-mean(sss)+2*mean(ddd)
hist(sss) # histogram of the boostrapped sample

mean(sss)# mean of the boostrapped sample
## [1] -0.1262749
mean(ddd)# sd of the boostrapped sample
## [1] 1.044444
low # this value is -2 for a N(0,1)
## [1] -2.215162
upper # this value is +2 for a N(0,1)
## [1] 1.962612