Question

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 diﬀerent sample sizes, and discuss it in the context of consistency.

Answer #1

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.

To use R/Rstudio do it
(a) Simulate a sample of size n = 30 from N(1,32), and calculate
the sample variance.
(b) Plot the histogram of your simulated sample in part (a) with
option breaks=10.
(c) Repeat (a) 100 times using a for loop, so you will have 100
sample variances. Plot the histogram of the 100 sample
variances.
(d) Calculate the mean and the variance of the 100 sample variances
in part (c). Is the mean close to 9?

To use R/Rstudio do it
"some require": set.seed(123) ,to use 123
(a) Simulate a sample of size n = 30 from N(1,32), and calculate
the sample variance.
(b) Plot the histogram of your simulated sample in part (a) with
option breaks=10.
(c) Repeat (a) 100 times using a for loop, so you will have 100
sample variances. Plot the histogram of the 100 sample
variances.
(d) Calculate the mean and the variance of the 100 sample variances
in part (c)....

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 5 minutes ago

asked 8 minutes ago

asked 18 minutes ago

asked 34 minutes ago

asked 42 minutes ago

asked 50 minutes ago

asked 52 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago