Sampling variability and bootstrapping
What this lesson covers
- Sample statistics vary from sample to sample.
- A bootstrap resample is the same size, drawn with replacement.
- Thousands of resamples show the spread of an estimate.
The bootstrap
- Take your one random sample.
- Draw a new sample of the same size with replacement.
- Calculate the statistic and repeat 1000 or more times.
- The spread of those results shows the uncertainty.
Reading a bootstrap
- 1000 resampled means, sorted from lowest.
- 2.5th percentile = 47.2
- 97.5th percentile = 53.8
- 95% interval: 47.2 to 53.8
One resample by hand
- The sample is 3, 5, 6, 8, 10, with mean 6.4. Draw five values with replacement, so a value can repeat.
- sample mean = 32 ÷ 5 = 6.4
- resample: 5, 5, 8, 3, 10
- resample mean = 31 ÷ 5 = 6.2
- repeat 1000 times or more
Try it: build the distribution
- Press the buttons to take resamples from a sample of 20. The bars build up, and the middle 95% appears as an interval.
Statistics explorer
Why it works
- A random sample looks roughly like its population, so resampling from it imitates taking new samples.
- If the sample is biased, the bootstrap copies that bias. It cannot fix a poor sample.
Try it: samples vary
Common mistakes
- Sampling without replacement.That only rebuilds the same sample.
- Thinking bootstrapping adds new data.It only measures uncertainty from what you have.
Your turn
A sample has 40 values. What size is each resample?
From 1000 sorted resample means, which positions give the 95% interval?
Which is sampled with replacement?
What must be true of the original sample?
Show answer
1. 40 2. The 25th and 975th 3. Each resample 4. It should be a random sample
Sample question: Achieved
A random sample of 8 Year 13 students gives their weekly hours of paid work: 12, 15, 9, 20, 15, 11, 18, 14. Describe how to make one bootstrap resample. One resample is 15, 9, 20, 20, 11, 14, 15, 12. Find the mean of the original sample and the mean of this resample.
Hint
A resample is the same size as the sample and is drawn with replacement, so a value can appear more than once.
Answer
Draw 8 values from the sample with replacement. Sample mean 14.25 hours, resample mean 14.5 hours.
Step by step
- A bootstrap resample copies the size of the original sample. Here that is 8 values.
- Draw the 8 values one at a time from the original sample, putting each one back before the next draw. That is what with replacement means.
- Because each value goes back, the same value can be picked twice. The 20 appears twice in the resample, and that is allowed.
- Classic mistake: drawing without replacement. Then you get the same 8 values in a new order, and the mean never changes.
- Original mean: add the values, 12 + 15 + 9 + 20 + 15 + 11 + 18 + 14 = 114, then divide by 8. 114 ÷ 8 = 14.25 hours.
- Resample mean: 15 + 9 + 20 + 20 + 11 + 14 + 15 + 12 = 116, and 116 ÷ 8 = 14.5 hours.
- Check: every value in the resample is one of the original values, and there are exactly 8 of them.
Full working
- resample size = 8same size as the sample
- draw with replacementvalues can repeat
- sample mean = 114 ÷ 8 = 14.25
- resample mean = 116 ÷ 8 = 14.5
- sample mean 14.25 h, resample mean 14.5 h
Sample questions: Merit
A random sample of 40 commuters on Auckland's Northern Busway gives their journey times in minutes. 1000 bootstrap resamples are taken and the median of each is found. Sorted from lowest, the 25th median is 41.5, the 26th is 41.8, the 975th is 48.2 and the 976th is 48.4. Give the 95% bootstrap confidence interval, write a sentence that interprets it, and explain why a classmate's statement "95% of these commuters take between 41.5 and 48.2 minutes" is wrong.
Hint
The middle 95% of 1000 sorted values runs from the 25th to the 975th, and the interval is about the population median, not about single people.
Answer
41.5 to 48.2 minutes. I am fairly sure the median journey time of all Northern Busway commuters is between 41.5 and 48.2 minutes. The classmate is wrong because the interval estimates the median, not the times of individual commuters.
Step by step
- A 95% bootstrap interval cuts off the lowest 2.5% and the highest 2.5% of the resample results.
- 2.5% of 1000 is 25. So the interval starts at the 25th value from the bottom.
- It ends 25 values from the top. 1000 − 25 = 975, so it ends at the 975th value.
- Read them off: the 25th is 41.5 and the 975th is 48.2. The 26th and 976th are distractors.
- So the interval is 41.5 to 48.2 minutes.
- To interpret it, name the population (all Northern Busway commuters), the variable (journey time) and the parameter (the median).
- Sentence: I am fairly sure the median journey time of all Northern Busway commuters is between 41.5 and 48.2 minutes.
- The classmate talks about individual commuters. The interval is about the median, one number for the whole population.
- Individual journey times spread much more widely than this. Many commuters will take less than 41.5 or more than 48.2 minutes.
- Check: 41.5 is below 48.2, and the interval sits in the middle of the sorted medians, as it should.
Full working
- 2.5% of 1000 = 25cut 25 from each end
- 25th value = 41.5lower limit
- 975th value = 48.2upper limit
- parameter: median journey time of all busway commuters
- interval is about the median, not individualsso the classmate is wrong
- 41.5 to 48.2 minutes
A bootstrap 95% confidence interval for the mean from a random sample of 50 is 8.4 to 11.6. Estimate the width of the interval if the sample size were 200, and if it were 800. What sample size would give an interval about 0.8 wide?
Hint
The width shrinks with √n: four times the sample size halves the width.
Answer
About 1.6 wide with n = 200, about 0.8 wide with n = 800, so a sample of about 800 is needed.
Step by step
- First find the width now: 11.6 − 8.4 = 3.2.
- Recall the rule: the width is proportional to 1 ÷ √n. Doubling n does not halve the width; you need four times as many.
- Going from 50 to 200 multiplies n by 4. √4 = 2, so the width is divided by 2.
- 3.2 ÷ 2 = 1.6 wide with n = 200.
- Going from 50 to 800 multiplies n by 16. √16 = 4, so the width is divided by 4.
- 3.2 ÷ 4 = 0.8 wide with n = 800.
- So a width of about 0.8 needs a sample of about 800.
- Classic mistake: thinking twice the sample gives half the width. Twice the sample only divides the width by √2, about 1.41.
- Check: 3.2 × √(50800) = 3.2 × 0.25 = 0.8.
Full working
- width = 11.6 − 8.4 = 3.2
- width ∝ 1√nsample to sample variation falls with √n
- n = 200: 3.2 ÷ √4 = 1.6n is 4 times bigger
- n = 800: 3.2 ÷ √16 = 0.8n is 16 times bigger
- n ≈ 800 for a width of 0.8
Sample questions: Excellence
A student weighs 30 players who stayed after training at her own rugby club. She takes 2000 bootstrap resamples and gets a 95% interval for the mean weight of 92.1 to 98.7 kg. She writes: "2000 resamples of 30 is like weighing 60000 players, so I can be sure the mean weight of all New Zealand club rugby players is between 92.1 and 98.7 kg. With 10000 resamples my interval would be even narrower." Evaluate each part of her statement.
Hint
Ask three things: was the sample random from the population she names, does resampling add new information, and what actually controls the width.
Answer
Her claim is not justified. The 60000 is not new data: every resample reuses the same 30 players, so the interval only reflects a sample of 30. Her players were volunteers from one club, so they do not represent all NZ club players, and the bootstrap copies that bias. More resamples would make the interval steadier, not narrower; only a bigger random sample would narrow it. At most she can describe players like those at her club, with caution.
Step by step
- Start with the 60000. 2000 × 30 = 60000 values, but they are copies drawn from the same 30 players.
- Bootstrapping never adds data. It uses the one sample to show how much the estimate could vary from sample to sample.
- So her information is still the weights of 30 players, and the interval is as wide as a sample of 30 allows.
- Next, the population. She names all New Zealand club rugby players, but she sampled one club.
- Worse, the players chose themselves by staying after training. That is a self-selected sample, not a random one.
- The bootstrap treats the sample as a stand-in for the population. If the sample is not like the population, every resample inherits that bias.
- In context: players at one club may be heavier or lighter than average, for example if it is a senior men's club rather than a junior or women's club.
- Now the 10000 resamples. More resamples make the interval's ends settle down, but the width depends on the sample size n, not on the number of resamples.
- To narrow the interval she needs more players, and to extend it to all NZ club players she needs a random sample from them.
- Conclusion: the claim is not supported. The interval describes, at best, players like those who stay after training at her club.
Full working
- 2000 × 30 = 60000but all copies of the same 30 players
- bootstrap adds no datait measures variation from one sample
- sample: volunteers at one clubnot random, not all NZ clubs
- bias is copied into every resample
- width set by n = 30, not by the number of resamples
- claim not supported; at most describes players like these, with caution
An Interislander ferry operator says "our typical delay is under 5 minutes". A random sample of 25 sailings is taken. The delays are strongly right-skewed, with a few over 40 minutes. Bootstrap 95% intervals are: mean delay 6.2 to 13.8 minutes, median delay 3.5 to 6.0 minutes. Which interval should be used to judge the claim, and does the sample support it? Justify your answer.
Hint
With strong skew the median describes the typical value better, and a claim is only supported if the whole interval is on one side of the claimed value.
Answer
Use the median interval, because the skew drags the mean up and the median better describes a typical sailing. The interval 3.5 to 6.0 minutes contains 5, so the median delay could be above or below 5 minutes: the sample does not support the claim, and it does not show it is false either. A larger random sample would be needed to decide.
Step by step
- The word typical points to the centre of the delays, so we must pick a measure of centre.
- The delays are strongly right-skewed: a few very long delays. These pull the mean up but barely move the median.
- You can see this in the intervals: the whole mean interval, 6.2 to 13.8, sits above most of the median interval, 3.5 to 6.0.
- So the median is the better measure of a typical sailing. Use the median interval.
- Now compare it with 5. The interval 3.5 to 6.0 contains 5.
- That means the population median could be below 5 (like 4) or above 5 (like 5.8). Both fit the data.
- So the sample does not support the claim that the typical delay is under 5 minutes.
- Classic mistake: saying the claim is proved false. Zero evidence for a claim is not evidence against it. It is simply unclear.
- Limitation: the sample is only 25 sailings, so the interval is wide. A larger random sample, across seasons and weather, would narrow it.
- Check: had we used the mean interval, the whole of it is above 5. That would wrongly reject the claim because of a few long delays.
Full working
- right-skewed: mean pulled upmedian better for typical
- use median interval 3.5 to 6.0 min
- 5 is inside 3.5 to 6.0median could be either side of 5
- not supported, not disprovedneed a larger random sample
- median interval; contains 5, so the claim is not supported
What to take away
- One sample can show its own uncertainty.
- It still has to be a random sample.
Report a mistake
More in AS 91582
Is your child on track?
Take the free placement test


