Statistics 6401, Fall 2012 1

Simulation Exercises

1. (L.L.N.) Demonstrate the Law of Large Numbers for the Normal Distribution.

• Sample n = 1000 Standard Normal random values and put them in a vector z.

• Write an R function to compute the cumulative mean.

• Create a vector x = (1, 2, ..., n).

• Compute the cumulative mean vector y from z and x.

• Approximate the probability that |y| > ϵ.

• Hint: Here is the R code needed for writing the cummean function.

  cummean = function(w){
          n = length(w)
          y = numeric(n)
          x = c(1:n)
          y = cumsum(w)
          y = y/x
          return(y)
  }

2. (C.L.T.) Demonstrate the Central Limit Theorem for the Normal and Exponential Distributions. • Sample k = 1000 samples of size n = 30 from the Normal(5, 2).

• Compute the means for each of the k samples.

• Draw a histogram of these k sample means.

• Describe the shape of the histogram.

• Do the above steps again with the Exp(λ = 1/3).

3. Demonstrate the independence of the sample mean and variance when sampling from the Normal(5, 2). • Sample k = 1000 samples of size n = 30 from the Normal(5, 2).

• Compute the sample means and standard deviations for each of the k samples.

• Plot the sample means versus the sample standard deviations.

• Compute the correlation between the sample means and standard deviations.

• Do the above steps again with the Exp(λ = 1/3).