In: Statistics and Probability
To better understand how the Law of Large Number (LLN) and the Central Limit Theory (CLT) works, we can use the following simulation to demonstrate them. (Note: attach the computer codes which implement the analysis in your answer) To demonstrate the Lindberg-Levy CLT, please generate 1000 sets of independent random samples, each has 1000 observations, from i.i.d X^2(5) distribution. First choose one set of the random samples and plot a histogram. Do you see a X^2(5) distribution? Denote the sample mean of each set of random samples as Z, and plot the histogram of Z. Do you see a normal distribution? What are the empirical mean and empirical variance of Z? Are they close to what CLT predicts?
1000 samples of 1000 observations of chisquare RVs are generated and mean of the observations is plotted as below.
Below the R code for one set of the random sample.
m <- 1000
n <- 1000
df <- 25
TC <- array (dim = c(m,n))
MTC <- array (dim = m)
for (i in 1:m)
{
TC[i,] <- rchisq(n,df)
MTC[i] <- mean(TC[i,])
}
hist(TC[4,],prob = T, breaks = 50, xlab = "X", main =
"Chisquare Distribution")
curve(dchisq(x,df), col="darkred", lwd=2, add=TRUE)
We see a Chisquare distribution.
Histogram of the mean is plotted below. Code below.
m <- 1000
n <- 1000
df <- 25
TC <- array (dim = c(m,n))
Z <- array (dim = m)
for (i in 1:m)
{
TC[i,] <- rchisq(n,df)
Z[i] <- mean(TC[i,])
}
hist(Z,prob = T, breaks = 50, xlab = "Z", main =
"Theoretical and Empirical Distribution")
curve(dnorm(x,df, sqrt(2*df/n)), col="darkred", lwd=2,
add=TRUE)
We see a normal distribution.
The empirical mean is 24.99798 and variance 0.0527