In: Statistics and Probability
Using your software of choice, I want you to experiment with the CLT using uniform random variables and various sample sizes. Generate n= 5 observations from the U(0,1) distribution and calculate the sample mean. Repeat this 500 times and construct a histogram of your 500 sample means. Repeat this for n= 20 and n= 50. Comment on the the normality of the three histograms (symmetry, is it bell shaped, etc.).
I have used R programming.Run the below programme.
# a histogram of 500 sample means
sample_means1<- 0
n1=500
for(i in 1:n1) {
sample_means1[i] <- mean(runif(5,0,1))
print(sample_means1[i])
}
hist(sample_means1,col="green",main="a histogram of 500 sample
means")
# a histogram of 20 sample means
sample_means2<- 0
n2=20
for(i in 1:n2) {
sample_means2[i] <- mean(runif(5,0,1))
print(sample_means2[i])
}
hist(sample_means2,col="red",main="a histogram of 20 sample
means")
## a histogram of 50 sample means
sample_means3<- 0
n3=50
for(i in 1:n3) {
sample_means3[i] <- mean(runif(5,0,1))
print(sample_means3[i])
}
hist(sample_means3,,col="blue",main="a histogram of 50 sample
means")
par(mfrow=c(3,1))
hist(sample_means1,col="green",main="a histogram of 500 sample
means")
hist(sample_means2,col="red",main="a histogram of 20 sample
means")
hist(sample_means3,,col="blue",main="a histogram of 50 sample
means")
Comment:- When we draw a histogram of 500 samples means we get a bell-shaped picture and this is present a normal distribution.
When we draw a histogram of 50 samples means we also get a bell-shaped picture and this presents a normal distribution.But in the case of 20 samples we can not get a bell-shaped picture.