R Simulation:
For n = 10, simulate a random sample of size n from N(µ,σ2), where µ = 1 and σ2 = 2; compute the sample mean. Repeat the above simulation 500 times, plot the histogram of the 500 sample means (does it mean that I can just use hist() method instead of plot() method). Now repeat the 500 simulations for n = 1,000. Compare these two sets of results with different sample sizes, and discuss it in the context of consistency.
norm <- rnorm(n = 10,mean = 1,sd = 2)
norm
x<-mean(norm)
x
#simulations 500 times
for(i in 1:500){
y=y+mean(rnorm(n = 10,mean = 1,sd = 2))
}
y=y/500
y
hist(y)
#500 simulations for n=1000
for(i in 1:500){
z=z+mean(rnorm(n = 1000,mean = 1,sd = 2))
}
z=z/500
z
Hope this helped you! Please comment below still if you have any doubts on this answer.
Get Answers For Free
Most questions answered within 1 hours.