Reference no: EM132171822
Using the nested for loops(i.e. for loop defined inside a for loop) to demonstrate the law of large numbers with R.
(a) Take sample from X~Uniform(3,7).
(b) Run your outer for loop from 10 to 2010 with step size 100 so that the sample size gets increased: n=10,110,210,...,2010
(c) Run the inner for loop to construct the sampling distribution of the mean with 100000 random numbers.
(d) Compute mean of the sampling distribution and standard deviations for each n in the outer loop and print them out one row, (e.g. print(c(mean,std)).
(e) Generate the histogram for each sample size n with fixed xlim=c(3.5,6.5) in the outer loop.
You may use par(mfrow=c(3,3)) before the loops begin to see the slide.