Read Appendix C.3 to learn about the Theorem of Large Numbers and the Central Limit Theorem.
(a) Draw 1000 realizations from a standard normal distribution using R and calculate the arithmetic mean. Repeat this process 1000 times. Evaluate the distribution of the arithmetic mean by drawing a kernel density plot and by calculating the mean and variance of it.
(b) Repeat the procedure in (a) with an exponential distribution with λ = 1. Interpret your findings in the light of the Central Limit Theorem.
(c) Repeat the procedure in (b) using 10,000 rather than 1000 realizations. How do the results change and why?
Table C.3 (1-\alpha) quantiles of the \chi^2-distribution. These values can also be obtained in R using the qchisq(p,df) command | ||||||
df | 1-\alpha | |||||
0.01 | 0.025 | 0.05 | 0.95 | 0.975 | 0.99 | |
1 | 0.0001 | 0.001 | 0.004 | 3.84 | 5.02 | 6.62 |
2 | 0.020 | 0.051 | 0.103 | 5.99 | 7.38 | 9.21 |
3 | 0.115 | 0.216 | 0.352 | 7.81 | 9.35 | 11.3 |
4 | 0.297 | 0.484 | 0.711 | 9.49 | 11.1 | 13.3 |
5 | 0.554 | 0.831 | 1.15 | 11.1 | 12.8 | 15.1 |
6 | 0.872 | 1.24 | 1.64 | 12.6 | 14.4 | 16.8 |
7 | 1.24 | 1.69 | 2.17 | 14.1 | 16.0 | 18.5 |
8 | 1.65 | 2.18 | 2.73 | 15.5 | 17.5 | 20.1 |
9 | 2.09 | 2.70 | 3.33 | 16.9 | 19.0 | 21.7 |
10 | 2.56 | 3.25 | 3.94 | 18.3 | 20.5 | 23.2 |
11 | 3.05 | 3.82 | 4.57 | 19.7 | 21.9 | 24.7 |
12 | 3.57 | 4.40 | 5.23 | 21.0 | 23.3 | 26.2 |
13 | 4.11 | 5.01 | 5.89 | 22.4 | 24.7 | 27.7 |
14 | 4.66 | 5.63 | 6.57 | 23.7 | 26.1 | 29.1 |
15 | 5.23 | 6.26 | 7.26 | 25.0 | 27.5 | 30.6 |
16 | 5.81 | 6.91 | 7.96 | 26.3 | 28.8 | 32.0 |
17 | 6.41 | 7.56 | 8.67 | 27.6 | 30.2 | 33.4 |
18 | 7.01 | 8.23 | 9.39 | 28.9 | 31.5 | 34.8 |
19 | 7.63 | 8.91 | 10.1 | 30.1 | 32.9 | 36.2 |
20 | 8.26 | 9.59 | 10.9 | 31.4 | 34.2 | 37.6 |
25 | 11.5 | 13.1 | 14.6 | 37.7 | 40.6 | 44.3 |
30 | 15.0 | 16.8 | 18.5 | 43.8 | 47.0 | 50.9 |
40 | 22.2 | 24.4 | 26.5 | 55.8 | 59.3 | 63.7 |
50 | 29.7 | 32.4 | 34.8 | 67.5 | 71.4 | 76.2 |
60 | 37.5 | 40.5 | 43.2 | 79.1 | 83.3 | 88.4 |
70 | 45.4 | 48.8 | 51.7 | 90.5 | 95.0 | 100.4 |
80 | 53.5 | 57.2 | 60.4 | 101.9 | 106.6 | 112.3 |
90 | 61.8 | 65.6 | 69.1 | 113.1 | 118.1 | 124.1 |
100 | 70.1 | 74.2 | 77.9 | 124.3 | 129.6 | 135.8 |
Quantiles of the F-Distribution. These quantiles can be obtained in R using the qf(p,df1,df2) command. |
(a) Random numbers of a normal distribution can be generated using the rnorm command. By default μ = 0 and σ = 1 (see ?rnorm), so we do not need to specify these parameters. We simply need to set n = 1000. The mean of the 1000 realizations can thus be obtained using mean(rnorm(1000)).We can, for example, write a for loop to repeat this process 1000 times. An empty (=NA) vector of size 1000 can be used to store and evaluate the results:
set.seed(24121980) R <- 1000 means <- c(rep(NA,R)) for(i in 1:R){means[i] <- mean(rnorm(1000))} mean(means) [1] -0.0007616465 var(means) [1] 0.0009671311 plot(density(means)) |
We see that the mean of the arithmetic means is close to zero, but not exactly zero. The variance is approximately σ²/n = 1/1000 = 0.001, as one would expect from the Central Limit Theorem. The distribution is symmetric, similar to a normal distribution, see Fig. B.17. It follows that \bar{X}_{n} is approximately N(μ, \frac{\sigma ^{2}}{n}) distributed, as one could expect from the Theorem of Large Numbers and the Central Limit Theorem. It is important to understand that \bar{X} is not fixed but a random variable which follows a distribution, i.e. the normal distribution.
(b) We can use the same code as above, except we use the exponential instead of the normal distribution:
means2 <- c(rep(NA,R)) for(i in 1:R){means2[i] <- mean(rexp(1000))} mean(means2) [1] 1.001321 var(means2) [1] 0.001056113 plot(density(means)) |
The realizations are i.i.d. observations. Once can see that, as in a), \bar{X}_{n} is approximately N(μ, \frac{\sigma ^{2}}{n} ) = N(1, 1/1000) distributed. It is evident that the X_{i} do not necessarily need to follow a normal distribution for \bar{X} to follow a normal distribution, see also Fig. B.18a.
(c) Increasing the number of repetitions makes the distribution look closer to a normal distribution, see Fig. B.18b. This visualizes that as n tends to infinity \bar{X}_{n} gets closer to a N(μ, \frac{\sigma ^{2}}{n} )-distribution.