Thompson (2012), Sampling 3rd Edition. Page 46, Daily Precipitation. CLT for finit Population.

Data

w=c(9.6,0.0,6.8,13.8,4.2,28.6,14.6,7.0,1.6,34.0,2.6,1.6,0.6,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,3.6,0.1,0.6,0.2,0.0,18.4,1.4,0.0,0.0,2.0,2.0,0.0,0.4,1.8,1.0,1.2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,8.0,12.0,3.8,3.6,1.0,0.1,0.2,9.8,3.8,4.2,0.0,0.2,0.0,0.6,0.1,5.4,0.0,0.0,0.0,0.4,11.4,8.6,0.6,1.4,3.6,13.6,11.4,0.0,0.1,6.0,7.4,0.1,0.0,0.1,0.8,0.1,9.8,5.6)
mean(w)
## [1] 3.238889
hist(w,20, main= paste("Weather data"))

Sample of size n=15 Draw the histogram to see its distrbution.

y15=numeric(0)
for(i in 1:10000)
  y15=c(y15,mean(sample(w,15)))
hist(y15,20)

Compute the coverage when n is 15

m=0
n=15
   N=length(w)
   mu=mean(w)
 for(i in 1:10000){
    sa=sample(w,n)
   L=mean(sa)+qnorm((1-0.95)/2)*sqrt((1-n/N)*var(sa)/n)
   U=mean(sa)+qnorm(1-(1-0.95)/2)*sqrt((1-n/N)*var(sa)/n)
   if(mu<U&&mu>L)m=m+1
  }
  cov=m/10000
print(paste("Coverage=",cov, "This is the fraction of confidence interval which contains the population mean,mu, where n=",n))
## [1] "Coverage= 0.8502 This is the fraction of confidence interval which contains the population mean,mu, where n= 15"

Sample of size n=30 Draw the histogram to see its distrbution.

y40=numeric(0)
for(i in 1:10000)
  y40=c(y40,mean(sample(w,40)))
hist(y40,20)

Compute Coverage When n is 30

m=0
n=40
   N=length(w)
   mu=mean(w)
 for(i in 1:10000){
    sa=sample(w,n)
   L=mean(sa)+qnorm((1-0.95)/2)*sqrt((1-n/N)*var(sa)/n)
   U=mean(sa)+qnorm(1-(1-0.95)/2)*sqrt((1-n/N)*var(sa)/n)
   if(mu<U&&mu>L)m=m+1
  }
  cov=m/10000
print(paste("Coverage=",cov, "This is the fraction of confidence intervals which contains the population mean,mu, where n=",n))
## [1] "Coverage= 0.9061 This is the fraction of confidence intervals which contains the population mean,mu, where n= 40"