3  The Central Limit Theorem

3.1 From one observation to one sample mean

In Chapter 2, one repetition usually generated one value of a random variable:

\[ X. \]

Now one repetition will generate an entire sample:

\[ X_1,X_2,\ldots,X_n. \]

The number of observations in the sample,

\[ n, \]

is called the sample size.

Suppose again that

\[ X\sim U(2,5). \]

This is the parent distribution. Every observation in every sample will be generated from this same parent distribution.

Because the observations are generated independently from the same parent distribution, they are independent and identically distributed, usually abbreviated iid.

The terms sample mean and sample average mean the same thing. We will usually use sample mean.

What changes from sample to sample are the realized values. Because the sample changes, the sample mean changes too.

If one sample contains \(n\) observations, its sample mean is

\[ \bar X = \frac{X_1+X_2+\cdots+X_n}{n}. \]

So one sample produces one sample mean:

\[ X_1,\ldots,X_n \quad\longrightarrow\quad \bar X. \]

Let the sample size be

\[ n=5. \]

n <- 5                                # Number of observations in one sample

x <- runif(n, min = 2, max = 5)       # Generate one sample from the parent U(2,5)
cat("sample =", round(x, 3), "\n")    # Print all observations in the sample
sample = 4.756 4.727 4.304 4.359 2.054 
x.bar <- mean(x)                       # Calculate the sample mean
cat("x.bar =", round(x.bar, 3), "\n") # Print the sample mean
x.bar = 4.04 

These five observations make one sample, and that sample gives us one value of \(\bar X\).

The important idea is

\[ \boxed{\text{one sample of size }n \longrightarrow \text{one }\bar X}. \]

Notice that \(n\) tells us how many observations are inside one sample.

3.2 Ten samples from the same parent distribution

One sample gives one sample mean.

To understand the distribution of \(\bar X\), we need many samples.

Just as in Chapters 1 and 2, it is useful to watch several repetitions explicitly. So now we generate 10 samples.

There are now two numbers to keep track of:

\[ n=\text{number of observations in each sample} \]

and

\[ R=\text{number of Monte Carlo repetitions (here, the number of samples we generate)}. \]

For now, let

\[ n=5 \qquad\text{and}\qquad R=10. \]

Remember: every sample still comes from the same parent distribution,

\[ X\sim U(2,5). \]

n <- 5                                # Number of observations in each sample
R <- 10                               # Number of Monte Carlo repetitions

x.bar <- rep(0, R)                    # Create space to save one mean from each sample

for (i in 1:R) {

  x <- runif(n, min = 2, max = 5)     # Generate one sample from the same U(2,5) parent
  x.bar[i] <- mean(x)                  # Calculate and save its sample mean

  cat("rep =", i,
      "sample =", round(x, 3),
      "x.bar =", round(x.bar[i], 3), "\n")
}
rep = 1 sample = 4.815 2.257 3.011 4.134 3.607 x.bar = 3.565 
rep = 2 sample = 3.468 2.771 2.355 3.043 2.497 x.bar = 2.827 
rep = 3 sample = 4.899 3.433 2.383 3.497 2.885 x.bar = 3.419 
rep = 4 sample = 3.943 3.603 2.286 3.319 3.94 x.bar = 3.418 
rep = 5 sample = 3.777 2.038 2.167 3.217 3.101 x.bar = 2.86 
rep = 6 sample = 3.213 3.827 2.28 2.063 4.894 x.bar = 3.255 
rep = 7 sample = 2.392 2.556 4.041 3.155 2.733 x.bar = 2.975 
rep = 8 sample = 4.907 4.963 3.984 2.187 3.761 x.bar = 3.961 
rep = 9 sample = 3.579 2.615 4.161 4.524 4.698 x.bar = 3.915 
rep = 10 sample = 4.983 4.185 2.146 4.191 2.559 x.bar = 3.613 

Now the repetition structure is different from the earlier chapters.

In Chapter 2, one repetition usually gave one value of \(X\).

Here, one repetition gives

\[ \boxed{ \text{one sample of size }n \rightarrow \text{one sample mean }\bar X }. \]

After \(R\) repetitions we have

\[ \bar X_1,\bar X_2,\ldots,\bar X_R. \]

The R output above lets us watch 10 different samples from the same parent distribution produce 10 different sample means.

The key distinction is

\[ \boxed{n=\text{observations in each sample}} \]

versus

\[ \boxed{R=\text{number of Monte Carlo repetitions}}. \]

Increasing \(R\) gives us more sample means with which to study the distribution of \(\bar X\).

Increasing \(n\) changes the sample mean itself and, as we will see, changes its distribution.

3.3 The distribution of the sample mean

We now know how to generate many sample means:

\[ \bar X_1,\bar X_2,\ldots,\bar X_R. \]

These sample means have their own distribution.

The distribution of a statistic across repeated samples is called its sampling distribution. Here, we are studying the sampling distribution of \(\bar X\).

To understand this distribution, we can ask the same three questions we asked about distributions in Chapter 2:

Where is it centered?

How spread out is it?

What is its shape?

Let’s answer these questions using the same parent distribution as before:

\[ X\sim U(2,5). \]

From Chapter 2, we know that

\[ \mu=3.5 \]

and

\[ \sigma^2=0.75. \]

Suppose we repeatedly draw samples of size

\[ n=5 \]

from this same parent distribution and calculate \(\bar X\) for each sample.

Center

The distribution of the sample mean has the same center as the parent distribution:

\[ E(\bar X)=\mu. \]

In our example,

\[ E(\bar X)=3.5. \]

Individual samples give different sample means, but across many samples those means are centered around 3.5.

Spread

The sample means are less spread out than the individual observations from the parent distribution.

Their variance is

\[ \operatorname{Var}(\bar X) = \frac{\sigma^2}{n}. \]

For our example,

\[ \operatorname{Var}(\bar X) = \frac{0.75}{5} = 0.15. \]

Compare this with the parent distribution:

\[ \operatorname{Var}(X)=0.75. \]

So averaging five observations reduces the variation.

As \(n\) increases,

\[ \frac{\sigma^2}{n} \]

gets smaller. Sample averages from larger samples therefore tend to be more tightly concentrated around \(\mu\).

Shape

What about the shape of the distribution?

This is where the Central Limit Theorem becomes important.

For sufficiently large \(n\), the distribution of the sample mean is approximately normal:

\[ \bar X \approx N\left(\mu,\frac{\sigma^2}{n}\right). \]

In our example,

\[ \bar X \approx N(3.5,0.15). \]

Notice something remarkable here. The parent distribution is uniform:

\[ X\sim U(2,5), \]

but the distribution of its sample means becomes approximately normal.

That is the central idea of the Central Limit Theorem.

Parent distribution versus distribution of the sample mean

The parent distribution describes the individual observations in each sample.

The distribution of \(\bar X\) describes sample means obtained from repeated samples from that same parent distribution.

We can summarize the difference:

Parent distribution \(X\) Distribution of \(\bar X\)
Center \(\mu=3.5\) \(\mu=3.5\)
Variance \(\sigma^2=0.75\) \(\sigma^2/n=0.15\)
Shape Uniform Approximately normal

The two distributions have the same center, but the sample means have less spread. And even though the parent distribution need not be normal, the distribution of the sample mean becomes approximately normal as \(n\) becomes sufficiently large.

The figure below shows the complete movement from the parent distribution to the distribution of sample means.

Figure 3.1: From a parent distribution to the distribution of the sample mean.

The visual message is

\[ \boxed{ \text{same center} \qquad \text{smaller spread} \qquad \text{approximately normal shape} }. \]

There is one important distinction to keep in mind:

\[ E(\bar X)=\mu \]

and

\[ \operatorname{Var}(\bar X)=\frac{\sigma^2}{n} \]

give us the center and spread of the sample mean.

The Central Limit Theorem tells us about its approximately normal shape.

3.4 Seeing the Central Limit Theorem with Monte Carlo

The Central Limit Theorem predicts that, for sufficiently large \(n\),

\[ \bar X \approx N\left(\mu,\frac{\sigma^2}{n}\right). \]

For our example,

\[ X\sim U(2,5), \]

with

\[ \mu=3.5 \]

and

\[ \sigma^2=0.75. \]

Using samples of size

\[ n=5, \]

the theoretical prediction is

\[ \bar X \approx N\left(3.5,\frac{0.75}{5}\right) = N(3.5,0.15). \]

1. Theoretical Prediction

The theoretical distribution of the sample mean is approximately

\[ \bar X \approx N(3.5,0.15). \]

2. Numerical Simulation

In the previous section we generated 10 samples so that we could see each sample and its corresponding sample mean.

Now increase the number of Monte Carlo repetitions to

\[ R=10{,}000. \]

n <- 5                                # Number of observations in each sample
R <- 10000                            # Number of Monte Carlo repetitions

x.bar <- rep(0, R)                    # Create space for the sample means

for (i in 1:R) {

  x <- runif(n, min = 2, max = 5)     # Generate one sample from the parent U(2,5)
  x.bar[i] <- mean(x)                  # Calculate and save its sample mean
}

cat("number of sample means =", length(x.bar), "\n")
number of sample means = 10000 
cat("mean of sample means =", round(mean(x.bar), 3), "\n")
mean of sample means = 3.499 
cat("variance of sample means =", round(var(x.bar), 3), "\n")
variance of sample means = 0.152 

After the simulation, we have

\[ \bar X_1,\bar X_2,\ldots,\bar X_{10000}. \]

These are 10,000 sample means, each calculated from a different sample of \(n=5\) observations drawn from the same parent distribution.

3. Comparison

The graph below compares the simulated distribution of the sample means with the normal distribution predicted by the Central Limit Theorem.

R’s dnorm() command uses the standard deviation, so we use

\[ \sqrt{0.15} \]

rather than \(0.15\).

hist(x.bar,
     probability = TRUE,
     breaks = 35,
     xlab = "Sample mean",
     main = "")

curve(dnorm(x, mean = 3.5, sd = sqrt(0.15)),
      add = TRUE,
      lwd = 2)
Figure 3.2: Monte Carlo distribution of sample means from X ~ U(2,5), with the normal distribution predicted by the Central Limit Theorem.

The comparison lets us check all three features.

Center

The simulated sample means are centered near

\[ 3.5. \]

Spread

Their theoretical variance is

\[ 0.15, \]

which is much smaller than the parent variance of \(0.75\).

Shape

The simulated distribution is close to the normal distribution predicted by the Central Limit Theorem.

So Monte Carlo lets us see the CLT directly:

\[ \boxed{ \text{generate a sample} \rightarrow \text{calculate }\bar X \rightarrow \text{repeat many times} \rightarrow \text{compare the distribution of }\bar X }. \]

Complete Monte Carlo Algorithm

1. Theoretical Prediction

If the parent distribution has mean \(\mu\) and variance \(\sigma^2\), then for sufficiently large \(n\),

\[ \bar X \approx N\left(\mu,\frac{\sigma^2}{n}\right). \]

2. Numerical Simulation

  1. Generate a sample of \(n\) observations from the parent distribution.
  2. Calculate the sample mean \(\bar X\).
  3. Save \(\bar X\).
  4. Repeat steps 1–3 \(R\) times.
  5. Examine the distribution of the \(R\) saved sample means.

3. Comparison

Compare the simulated distribution of the sample means with

\[ N\left(\mu,\frac{\sigma^2}{n}\right). \]

3.5 Different parent distributions, same result

The parent distribution does not have to be normal.

It can be discrete, flat, or strongly skewed. When we repeatedly draw samples and calculate their averages, the distribution of those sample means tends to become approximately normal.

The same logic applies to other parent distributions, including \(F\) and Student \(t\) distributions, provided the parent distribution has a finite mean and variance.

Let’s look at three very different parent distributions.

For all three examples, we will use the same sample size,

\[ n=30, \]

and the same number of Monte Carlo repetitions,

\[ R=10{,}000. \]

Keeping \(n\) and \(R\) the same lets us focus on what happens when the parent distribution changes.

Three very different parent distributions

First, consider a binary random variable:

\[ X= \begin{cases} 1 & \text{with probability }0.5,\\ 0 & \text{with probability }0.5. \end{cases} \]

This parent distribution has only two possible outcomes.

Next, consider our familiar uniform distribution:

\[ X\sim U(2,5). \]

This parent distribution is flat.

Finally, consider

\[ X\sim\chi^2(2). \]

This parent distribution is strongly right-skewed.

These distributions look very different.

Monte Carlo simulation

For each parent distribution we do exactly the same thing:

  1. Draw a sample of \(n=30\) observations.
  2. Calculate the sample mean \(\bar X\).
  3. Save the sample mean.
  4. Repeat \(R=10{,}000\) times.
  5. Look at the distribution of the saved sample means.

The only thing that changes is the parent distribution from which each sample is drawn.

n <- 30
R <- 10000

# Binary parent distribution
xbar.binary <- rep(0, R)

for (i in 1:R) {
  x <- sample(c(0, 1), size = n, replace = TRUE)  # One sample from the binary parent
  xbar.binary[i] <- mean(x)                       # Save its sample mean
}

# Uniform parent distribution
xbar.uniform <- rep(0, R)

for (i in 1:R) {
  x <- runif(n, min = 2, max = 5)                 # One sample from U(2,5)
  xbar.uniform[i] <- mean(x)                       # Save its sample mean
}

# Chi-square parent distribution
xbar.chisq <- rep(0, R)

for (i in 1:R) {
  x <- rchisq(n, df = 2)                          # One sample from chi-square(2)
  xbar.chisq[i] <- mean(x)                        # Save its sample mean
}

cat("binary: mean =", round(mean(xbar.binary), 3),
    "variance =", round(var(xbar.binary), 3), "\n")
binary: mean = 0.5 variance = 0.008 
cat("uniform: mean =", round(mean(xbar.uniform), 3),
    "variance =", round(var(xbar.uniform), 3), "\n")
uniform: mean = 3.499 variance = 0.025 
cat("chi-square: mean =", round(mean(xbar.chisq), 3),
    "variance =", round(var(xbar.chisq), 3), "\n")
chi-square: mean = 2.009 variance = 0.133 

The figure below shows the parent distributions in the top row and the corresponding distributions of sample means in the bottom row.

Figure 3.3: Very different parent distributions can produce approximately normal distributions of sample means. The top row shows the parent distributions; the bottom row shows Monte Carlo distributions of the corresponding sample means.

The parent distributions in the top row look dramatically different.

The distributions of the sample means in the bottom row are all approximately bell-shaped.

The parent distributions themselves do not become normal. They remain binary, uniform, and chi-square.

It is the distribution of the sample mean

\[ \bar X \]

that becomes approximately normal.

Center and spread still follow the same rules

Although the three parent distributions look very different, the same results apply in every case:

\[ E(\bar X)=\mu \]

and

\[ \operatorname{Var}(\bar X)=\frac{\sigma^2}{n}. \]

So the distribution of the sample mean has the same center as its parent distribution, but a smaller spread.

With \(n=30\):

Parent distribution Parent mean \(\mu\) Parent variance \(\sigma^2\) Mean of \(\bar X\) Variance of \(\bar X\)
Binary \(0/1\) \(0.5\) \(0.25\) \(0.5\) \(0.25/30\)
\(U(2,5)\) \(3.5\) \(0.75\) \(3.5\) \(0.75/30\)
\(\chi^2(2)\) \(2\) \(4\) \(2\) \(4/30\)

The values of the center and spread differ across the three examples because their parent distributions have different \(\mu\)’s and \(\sigma^2\)’s.

But the rule is always the same:

\[ \boxed{ \text{center }=\mu, \qquad \text{variance }=\frac{\sigma^2}{n}, \qquad \text{shape }\approx\text{ normal} }. \]

So the binary sample means cluster around \(0.5\), the uniform sample means cluster around \(3.5\), and the chi-square sample means cluster around \(2\).

They do not all approach the same normal distribution. Each approaches the normal distribution appropriate for its own parent mean and variance:

\[ \bar X\approx N\left(\mu,\frac{\sigma^2}{n}\right). \]

The main message is

\[ \boxed{ \text{very different parent distributions} \longrightarrow \text{approximately normal distributions of }\bar X }. \]

The normal approximation is not equally good for every \(n\). In general, the approximation improves as \(n\) increases, and a strongly skewed parent distribution may require a larger \(n\) than a more symmetric parent distribution.

For now, the main point is more important:

The normal shape of the distribution of \(\bar X\) does not require the parent distribution itself to be normal.

3.6 A 95% probability interval for the sample mean

The Central Limit Theorem tells us that, for sufficiently large \(n\),

\[ \bar X \approx N\left(\mu,\frac{\sigma^2}{n}\right). \]

Once we know the distribution of \(\bar X\), we can ask a familiar question from Chapter 2:

What interval contains \(\bar X\) with probability 0.95?

For an approximately normal distribution, a 95% probability interval is

\[ \boxed{ \mu-1.96\sqrt{\frac{\sigma^2}{n}} < \bar X < \mu+1.96\sqrt{\frac{\sigma^2}{n}} } \]

or, more compactly,

\[ \boxed{ \mu\pm1.96\sqrt{\frac{\sigma^2}{n}} }. \]

Example

Return to our familiar parent distribution:

\[ X\sim U(2,5). \]

Its center and spread are

\[ \mu=3.5, \qquad \sigma^2=0.75. \]

Suppose each sample contains

\[ n=30 \]

observations.

According to the Central Limit Theorem,

\[ \bar X \approx N\left(3.5,\frac{0.75}{30}\right). \]

Therefore, the 95% probability interval for \(\bar X\) is

\[ 3.5 \pm 1.96\sqrt{\frac{0.75}{30}}. \]

Calculate the interval in R.

mu <- 3.5
sig2 <- 0.75
n <- 30

lower <- mu - 1.96 * sqrt(sig2 / n)      # Lower endpoint
upper <- mu + 1.96 * sqrt(sig2 / n)      # Upper endpoint

cat("95% probability interval =",
    round(lower, 3), "to", round(upper, 3), "\n")
95% probability interval = 3.19 to 3.81 

The figure below shows this interval on the distribution of the sample mean.

Figure 3.4: A 95% probability interval for the sample mean. The shaded area is 95% of the approximate distribution of X-bar.

This is a probability interval for the distribution of \(\bar X\), not for the parent distribution of \(X\).

1. Theoretical Prediction

The theoretical prediction is

\[ P\left( \mu-1.96\sqrt{\frac{\sigma^2}{n}} < \bar X < \mu+1.96\sqrt{\frac{\sigma^2}{n}} \right) \approx0.95. \]

For our example,

\[ P(3.190<\bar X<3.810)\approx0.95. \]

2. Numerical Simulation

We can check this probability directly with Monte Carlo simulation.

Here, one repetition means

\[ \boxed{ \text{draw a sample of size }n \rightarrow \text{calculate }\bar X \rightarrow \text{check whether }\bar X\text{ is inside the interval} }. \]

Start with 10 repetitions so we can watch what happens.

R <- 10
success.total <- 0

for (i in 1:R) {

  x <- runif(n, min = 2, max = 5)       # Draw one sample from the parent distribution
  x.bar <- mean(x)                       # Calculate its sample mean

  success <- 0                           # Start this repetition as a failure

  if ((x.bar > lower) && (x.bar < upper)) {
    success <- 1                         # Success if the sample mean is inside the interval
  }

  success.total <- success.total + success

  cat("rep =", i,
      "x.bar =", round(x.bar, 3),
      "success =", success,
      "total =", success.total, "\n")
}
rep = 1 x.bar = 3.465 success = 1 total = 1 
rep = 2 x.bar = 3.228 success = 1 total = 2 
rep = 3 x.bar = 3.507 success = 1 total = 3 
rep = 4 x.bar = 3.119 success = 0 total = 3 
rep = 5 x.bar = 3.582 success = 1 total = 4 
rep = 6 x.bar = 3.464 success = 1 total = 5 
rep = 7 x.bar = 3.666 success = 1 total = 6 
rep = 8 x.bar = 3.499 success = 1 total = 7 
rep = 9 x.bar = 3.518 success = 1 total = 8 
rep = 10 x.bar = 3.63 success = 1 total = 9 
p.hat <- success.total / R
cat("p.hat =", round(p.hat, 3), "\n")
p.hat = 0.9 

With only 10 repetitions, the simulated probability may be some distance from \(0.95\).

Now use many repetitions.

R <- 10000
success.total <- 0

for (i in 1:R) {

  x <- runif(n, min = 2, max = 5)       # Draw one sample from the same parent distribution
  x.bar <- mean(x)                       # Calculate its sample mean

  if ((x.bar > lower) && (x.bar < upper)) {
    success.total <- success.total + 1
  }
}

p.hat <- success.total / R               # Fraction of sample means inside the interval

cat("Monte Carlo probability =", round(p.hat, 3), "\n")
Monte Carlo probability = 0.948 
cat("Theoretical probability = 0.950\n")
Theoretical probability = 0.950

3. Comparison

The theoretical prediction is

\[ p\approx0.95. \]

The Monte Carlo simulation gives

\[ \hat p = \frac{\text{number of sample means inside the interval}}{R}. \]

Compare

\[ \hat p\approx0.95. \]

About 95% of the sample means generated from repeated samples should fall inside the interval.

Complete Monte Carlo Algorithm

1. Theoretical Prediction

According to the Central Limit Theorem,

\[ \bar X \approx N\left(\mu,\frac{\sigma^2}{n}\right). \]

Therefore, a 95% probability interval for \(\bar X\) is

\[ \left[ \mu-1.96\sqrt{\frac{\sigma^2}{n}}, \; \mu+1.96\sqrt{\frac{\sigma^2}{n}} \right]. \]

2. Numerical Simulation

  1. Generate a sample of \(n\) observations from the parent distribution.
  2. Calculate the sample mean \(\bar X\).
  3. Count a success if \(\bar X\) falls inside the predicted interval.
  4. Repeat steps 1–3 \(R\) times.
  5. Calculate

\[ \hat p = \frac{\text{number of successes}}{R}. \]

3. Comparison

Compare

\[ \hat p\approx0.95. \]

3.7 What are we trying to understand?

The main lesson in this chapter is how we move from a parent distribution to the distribution of the sample mean.

We start with a parent distribution, draw a sample

\[ X_1,\ldots,X_n, \]

calculate

\[ \bar X, \]

and repeat this process many times. The resulting values

\[ \bar X_1,\ldots,\bar X_R \]

form the distribution of the sample mean.

The relationship between the two distributions is:

Parent distribution Distribution of the sample mean
Random variable \(X\) \(\bar X\)
What it describes Individual observations in each sample Averages across repeated samples
Center \(\mu\) \(\mu\)
Variance \(\sigma^2\) \(\sigma^2/n\)
Shape Can have many shapes Approximately normal for sufficiently large \(n\)

The main results are therefore

\[ \boxed{E(\bar X)=\mu} \]

\[ \boxed{\operatorname{Var}(\bar X)=\frac{\sigma^2}{n}} \]

and, for sufficiently large \(n\),

\[ \boxed{ \bar X \approx N\left(\mu,\frac{\sigma^2}{n}\right) }. \]

Keep the two roles of \(n\) and \(R\) separate:

\[ \boxed{n=\text{number of observations in each sample}} \]

\[ \boxed{R=\text{number of Monte Carlo repetitions}}. \]

The observations inside each sample come from the parent distribution.

The sample means obtained across repeated samples form the distribution of \(\bar X\).

3.8 Where we go next

So far, we have treated quantities such as

\[ \mu \qquad\text{and}\qquad \sigma^2 \]

as known.

That allowed us to start with a parent distribution and predict the distribution of \(\bar X\).

For example, knowing \(\mu\) and \(\sigma^2\) allowed us to ask:

\[ \text{Where is }\bar X\text{ likely to fall?} \]

In real data, we usually face the problem in the opposite direction.

We observe one sample,

\[ X_1,\ldots,X_n, \]

and quantities such as the population mean \(\mu\) are unknown.

Then the question becomes:

\[ \boxed{ \text{If we observe }\bar X,\text{ what can we learn about the unknown }\mu? } \]

That takes us from probability and the Central Limit Theorem to statistical inference.