Download z[i]=mean(sample(c(0:9),10,replace=T))

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Central limit theorem wikipedia, lookup

Transcript
• This set of slides should be a review of sampling
distributions from your first class in statistics...
• When sampling from a population, we’ll assume the
sample of size n is i.i.d. Often we regard the population
as infinite though finite populations require some
additional attention.
• We consider the i.i.d. sample of size n as X1 , X 2 , ... X n
1
and we know that the sample mean is given as X   X i
n
Then, X

has mean= m and standard deviation = n
If the population is finite of size N, then modify the s.d. of
the mean with the so-called finite population correction
N n
N 1
• The Central Limit Theorem (Theorem 6.2) says that if the
sample size is large enough, then the distribution of the
sample mean approaches the normal distribution with
mean and standard deviation given on the previous
page.
• If the population is actually normal itself, then the sample
mean has exactly a normal distribution
• Let’s write some R code to illustrate this theorem...
– look at the example given at the beginning of section 6.2.
– take 50 random samples of size n=10 from a population having
the discrete uniform distribution .
– then analyze these 50 samples- what should their shape look
like (do a histogram and a normal quantile plot)? what should
their center look like (look at the mean)? what about spread
(look at the standard deviation)?
#first fill a vector z with 50 zeros
z<-rep(0,50)
#now use the sample function to select with
#replacement a sample of size 10 from {0,1,2,...,9}
sample(c(0:9),10, replace=T) #for example
#now take the mean of these 10 numbers
mean(sample(c(0:9),10, replace=T))
#now do this 50 times, saving the means in z
for (i in 1:50) {
z[i]=mean(sample(c(0:9),10,replace=T))}
z #to show the 50 means you got...
#try hist and qqnorm on z to check for normality
#and mean and sd to compare with the values the CLT
#says you should getting...
• HW: For Monday after the break... Read sections 6.1,
6.2 and begin 6.3. Do exercises # 6.1-6.3, 6.9-6.13,
6.17