C.a – Run the following R commands. Please spend some time trying understand the code well.Please describe the distribution that you obtain.
rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
set.seed(1239)
r1 <- rnorm2(100,25,4)
r2 <- rnorm2(50,10,3)
samplingframe <- c(r1,r2)
hist(samplingframe, breaks=20,col = "pink")
The sampling frame comes from cancatinating two different random sampling from two different normal distributions. It is not a normal distribution although each of them comes from a normal distribution.
C.b – Draw 50 samples of size 15, and plot the sampling distribution of means as a histogram.
cur <- c(1:50)
for(i in 1:50){
cur[i]=mean(sample(samplingframe,15,replace = TRUE))
}
hist(cur, main = "Distribution of means for 50 samples of size 15",xlab = "sample", ylab = "sample mean", col = "blue")
C.c – Draw 50 samples of size 45, and plot the sampling distribution of means as a histogram.
cur2 <- c(1:50)
for(i in 1:50){
cur2[i]=mean(sample(samplingframe,45,replace = TRUE))
}
hist(cur2, main = "Distribution of means for 50 samples of size 45",xlab = "sample", ylab = "sample mean", col = "blue")
C.d – Make sure that the distributions in parts b and c are on the same plot. Explain the three histograms in terms of their differences and similarities.
library(lattice)
histogram( ~ sapply(cur, mean) + sapply(cur2, mean), xlab = "Samples", ylab = "Sample means")
It is obvious that as the size of samples increase, our histogram converges to the mean of our poplulation which is 20.
C.e – Explain CLT in your own words. Restrict your response to less than 50 words:
If we want to make an estimation of the mean, sum or etc. of our population by sampling, we can choose samples out of our population, calculate the desired value for the samples and plot it on a histogram. as we increase the number and size of samples, our histogram converges to the exact value for our population. this is the concept of CTL.
C.g – Does this exercise help you understand CLT? If so why? If not, why not? Restrict your response to less than 50 words:
I knew this concept but I believe better helps to understand this concept, if the students could see what happens when the number of samples increase as well as the size of samples.