Averages Pile Up
Average the hold times of 30 random callers, again and again, and see what shape the averages make. You'll use R.
Assumes: mean, standard deviation and the normal (bell) curve, and pressing Run on R code. In R you'll write one short piece of code at a time.
1. The population: 10,000 calls to a helpline
Last month a helpline took 10,000 calls. For each one we know how many minutes the caller waited on hold. These 10,000 numbers are our population: every case we care about.
Press Run below. R makes the 10,000 hold times, draws their histogram, and prints two numbers that describe them:
- μ (“mu”), the population mean: the average hold time over all 10,000 calls.
- σ (“sigma”), the population standard deviation: how far a typical call is from μ.
Read the histogram
Which describes the population's shape?
The plan for steps 3 and 4
- Population: 10,000 calls
- Pick 30 at random
- Average them: one x̄
- Repeat 10,000 times
- Histogram of the 10,000 x̄'s
n is the sample size, how many calls go into each average: here n = 30. x̄ (“x-bar”) is the sample mean, the average of one sample.
The histogram of all those x̄'s approximates the sampling distribution of the sample mean: how sample means vary from one random sample to the next.
2. Predict the pile of averages
The population is skewed right, with mean about 20 minutes and SD about 21 minutes. Now imagine the plan on the left: 10,000 random samples of 30 calls, one average from each.
Before running anything: the 10,000 averages will pile up into a histogram shaped like…
Locked in. Steps 3 and 4 build the pile of averages in R, and step 5 puts it next to the population so you can check your prediction.
3. One sample, one average
First, a single sample. sample(pop, size = …, replace = TRUE) picks calls at random from pop. replace = TRUE means a picked call goes back in, so every pick is from the full population and the picks are independent of each other.
Your task: the code picks only 1 call. Make it pick a sample of 30.
- Press Run as it is: one hold time, and its “average” is just itself.
- Change
size = 1tosize = 30, and Run again. - Run it two more times, and watch
xbar.
Hint 1
The number aftersize = is how many calls R picks.Hint 2
The first line should readone_sample <- sample(pop, size = 30, replace = TRUE).What did you see?
You ran the same code three times and got three different values of xbar. Why?
4. Ten thousand samples, ten thousand averages
Now do step 3 over and over with a for loop, which repeats the lines inside { }, and keep every average.
| Line | What it does |
|---|---|
| xbars <- numeric(reps) | 10,000 empty slots, one for each sample's average. |
| for (i in 1:reps) { … } | Repeat 10,000 times. i counts which sample it is: 1, 2, 3, … |
| one_sample <- sample(…) | A fresh random sample of 30 calls, as in step 3. |
| xbars[i] <- … | Store this sample's average in slot number i. |
| hist(xbars, …) | The histogram of all 10,000 averages, on the same 0–100 scale as the population. |
Your task: one line inside the loop stores NA (“no value”) instead of the sample's average. Replace that NA with the code that averages one_sample, as you did in step 3.
- Press Run as it is: R says
xbarsis still empty. - Replace
NAon thexbars[i]line, then Run again (it may take a few seconds).
Hint 1
In step 3 you averaged a sample withmean(one_sample).Hint 2
The line should readxbars[i] <- mean(one_sample).You've just simulated a sampling distribution: draw many samples, average each one, and collect the averages. Step 5 compares the result with your prediction.
Single calls against averages of 30, on the same scale
5. Your prediction against the pile
On the left: the population (one bar per 2 minutes of hold time) and your 10,000 averages, on the same 0–100 scale. Compare their center, spread and shape.
You predicted the averages would keep the population's right skew and its 0–100 spread. That's a natural guess: they come from the same skewed calls. But look at the lower histogram: no average is anywhere near 0 or 100.
You predicted a bell around 20, as wide as the population. The center and shape are right. But look at the lower histogram's width: it's far narrower than the population.
You predicted the averages would spread evenly from 0 to 100. Look at the lower histogram: the averages bunch tightly around 20, and none come near 0 or 100.
Some people predict a narrow, roughly bell-shaped hill around 20 instead.
Look at the chart. Why is that prediction better than yours? Think about what happens to the few very long waits when each one is averaged in with 29 other calls.
Why averages bunch up. A sample of 30 almost always mixes a few long waits with many short ones, so its average lands near the middle. To average 60 minutes, nearly all 30 calls would have to be long, which almost never happens. So the extremes disappear, the spread shrinks, and the averages pile up nearly evenly on both sides of μ.
Try it on a new case: one die roll is equally likely to be 1, 2, 3, 4, 5 or 6, a flat shape. The average of 30 rolls lands between 3 and 4 about 9 times in 10, in a narrow hill around 3.5. Same reason: it takes many high rolls in a row to pull an average far from the middle.
You predicted a narrow, roughly bell-shaped hill around 20, and the lower histogram shows exactly that: centred where the population's mean is, far narrower, and nearly symmetric.
Some people expect the averages to keep the population's right skew: “the averages come from the same skewed calls, so a few very long waits should still drag the pile out to the right.”
How would you explain to them why the pile of averages is narrow and close to symmetric?
Why averages bunch up. A long wait does get into some samples, but it's averaged with 29 other calls, mostly short ones, so it nudges the average rather than dragging it far out. To average 60 minutes, nearly all 30 calls would have to be long, which almost never happens. A little of the skew remains (averages of 30 lean very slightly right), which step 7 explores.
Try it on a new case: one die roll is equally likely to be 1, 2, 3, 4, 5 or 6, a flat shape. The average of 30 rolls lands between 3 and 4 about 9 times in 10, in a narrow hill around 3.5.
6. Center and spread, by formula
The pile of averages has a name: the sampling distribution of the sample mean. Its standard deviation has a name too: the standard error (SE). It measures how far a typical sample mean lands from μ.
The population's SD is σ ≈ 21 minutes. Before you run the cell below: the SD of the 10,000 averages of 30 calls (the SE) is about…
The formula for both: the sampling distribution is centred at μ, and its SE is σ ÷ √n, where n is the sample size.
Your task: replace the NA with the square root of 30, the sample size. In R, sqrt(16) is √16 = 4.
Hint 1
Each sample in step 4 had 30 calls, so n = 30.Hint 2
The line should readse_formula <- sigma / sqrt(30).If mean(xbars) and se_sim show NA, the loop in step 4 hasn't run with your fix yet: run it there first.
Your prediction
You predicted about 4 minutes, and that's right: the cell gives about 3.9 both ways, by simulation and by σ ÷ √30 = 21.4 ÷ 5.48. Averaging 30 calls makes the spread √30 ≈ 5.5 times smaller. One step further: averages of 100 calls would have an SE of about 21.4 ÷ 10 ≈ 2.1 minutes.
You predicted the averages would spread as much as single calls. That mixes up two distributions: σ ≈ 21 describes single calls; the SE describes averages, which bunch together (step 5's lower histogram). The cell gives about 3.9 both ways, by simulation and by σ ÷ √30. One step further: averages of 100 calls would have an SE of about 21.4 ÷ 10 ≈ 2.1 minutes.
You predicted about 0.7, which is σ ÷ 30. The spread does shrink, but with the square root of n: σ ÷ √30 = 21.4 ÷ 5.48 ≈ 3.9, which is what the cell shows by simulation too. One step further: averages of 100 calls would have an SE of 21.4 ÷ √100 = 21.4 ÷ 10 ≈ 2.1 minutes, not 0.2.
You predicted the averages would vary more than single calls. Averaging does the opposite: long and short waits cancel within a sample, so averages vary less (step 5's lower histogram). The cell gives about 3.9 both ways, by simulation and by σ ÷ √30. One step further: averages of 100 calls would have an SE of about 21.4 ÷ 10 ≈ 2.1 minutes.
If each sample had 120 calls instead of 30 (four times as many), the SE would be…
7. Shape: how big must n be?
The Central Limit Theorem (CLT) says that for samples of independent random draws, the sampling distribution of the mean gets closer to a normal (bell) curve as n grows, whatever the population's shape. How big n must be depends on the population.
For this skewed population, from about which sample size do the averages look close to normal?
You predicted about n = 30. Below, click n = 2, 5 and 30 in turn: at 2 and 5 the QQ dots still curve up at the right end (a right tail); by 30 they follow the line closely, apart from a slight bend at the far ends. That's why textbooks quote n ≈ 30, a rule of thumb for populations that aren't too skewed. One step further: for a symmetric population, such as heights, the averages look normal at much smaller n.
You predicted the averages would look normal already at n = 2 or 5. Click those buttons below: the histogram still leans right and the QQ dots curve up at the right end, because a single long wait still pulls an average of 2 or 5 calls a long way. By n = 30 they follow the line closely. One step further: for a symmetric population, such as heights, small n like 5 would already be enough; skew is what makes the CLT need more.
You predicted averages of a skewed population stay skewed. At n = 2 and 5 they do lean right; but click n = 30 and 100 below: the QQ dots follow the line closely. That's the CLT: averaging washes out the population's shape as n grows, whatever the shape. One step further: the more skewed the population, the larger n must be, but enough averaging always brings the bell.
How to read a normal QQ plot (the right-hand plot below). Each dot is one average, placed against where it would sit if the averages were exactly normal. Dots on the straight line: normal. Dots that bend away from the line at the ends: not normal (here, a curve bending upward at the right means a long right tail).
Pick a sample size. R takes 5,000 samples of that size, averages each one, and draws the histogram and the QQ plot.
8. Say it in your own words
In 2–3 sentences: what did the loop in step 4 do, and what does the histogram of xbars show? Use the words sample, sample mean and sampling distribution.
One way to say it. The loop took 10,000 random samples of 30 calls from the population, worked out each sample's mean, and stored the 10,000 means in xbars. Their histogram approximates the sampling distribution of the sample mean: how much x̄ varies from one random sample to the next. It is centred at μ, its spread (the standard error) is σ ÷ √n, and for large enough n it is close to normal, even though the population is skewed.
Compare with yours: did you say that the histogram shows averages, not single calls? That's the part most often left out, and the difference between the population and the sampling distribution.
9. Check yourself
A bakery's delivery times have mean 40 minutes and SD 15 minutes, and are skewed right. A manager averages a random sample of 36 deliveries. Over many such samples, the averages would pile up…
How sure were you?
You should now be able to:
- tell apart the population, one sample, and the sampling distribution of the sample mean (steps 1, 3, 5);
- give the center (μ) and spread (SE = σ ÷ √n) of the sampling distribution, and say how the SE changes with n (step 6);
- say when the sampling distribution is close to normal, and why skew needs a larger n (step 7).
If one of these isn't clear yet, go back to the step in brackets and rerun its code.
Welcome back: two quick questions
Single phone batteries last 20 hours on average, with SD 6 hours. Averages of random samples of 9 batteries have an SD of about…
To cut the standard error of a sample mean in half, you need…
Assumptions
- dataThe 10,000 hold times are made up, not real helpline data: a Beta(0.5, 2) distribution scaled to 0–100 minutes and rounded to 0.1 (set.seed(17)), with mean about 20 and SD about 21.
- simplificationSamples are drawn with replacement, so draws are independent, the condition the CLT needs.
- parameterStep 4: 10,000 samples of n = 30 (set.seed(50)). Step 7: 5,000 samples for each n of 1, 2, 5, 10, 30 and 100.
- interpretation“Close to normal” is judged by eye from the QQ plot; n ≈ 30 is a rule of thumb, not a theorem.
Left out: sampling without replacement and the finite-population correction, using a sample's own SD when σ is unknown, and probability calculations with z-scores (the in-class problem).