#50 random variable N~(mean=5,0.5)
rnorm(n = 20,mean = 5,sd = 2.5)
## [1] 6.051025 4.297109 6.342796 4.997242 4.802378 4.440742 4.483932 1.526777
## [9] 6.022288 7.708451 5.068995 3.508722 4.831832 5.463063 1.224606 8.578725
## [17] 5.174429 2.775761 6.362961 6.381170
#create a population (N=50,mean=5,sd=0.5) then take a sample size 10 with & with out replacement
set.seed(13)
a<-rnorm(n=50,5,.5)
sample(x =a,size = 10,replace = TRUE )
## [1] 4.071986 4.453203 5.050170 5.351113 5.698216 5.310092 5.423899 4.942781
## [9] 5.614753 5.571263
sample(x =a,size = 10,replace = FALSE )
## [1] 4.817309 4.270342 5.138574 5.074677 4.636949 5.704177 4.697129 5.887582
## [9] 4.833566 5.571263
# Following are the number of students of 53 primary SCHOOL .draw a sample with & without replacement of size 8
b<-c(2050,1022,965,732,1032,1935,1602,1453,1303,2053,1666,1777,1565,1444,1333,1222,1111,1000,1850,1750,1650,1550,1450,1350,1250,1150,1050,950,850,750,1970,1870,1680,1980,2080,2180,2053,1880,679,579,977,1001,1330,1440,1553,1663,1773,1883,983,883,1953,1851,1224)
length(b)
## [1] 53
mean(b)
## [1] 1440.189
var(b)
## [1] 187714.1
set.seed(13)
c<-sample(x = b,size = 8,replace = TRUE)
d<-sample(x = b,size = 8,replace = FALSE)
c
## [1] 1350 965 2053 2053 1565 1935 1883 1550
#a) estimate average size
mean(c)
## [1] 1669.25
mean(d)
## [1] 1182.75
#B :estimate the standard error [se=sqrt((1-f)/n*s^2)]
sqrt((1-(8/53))/8*var(c))
## [1] 125.1977
m<-sqrt((1-(8/53))/8*var(d))
m
## [1] 126.8979
seyhat<-(53*m)
seyhat
## [1] 6725.589