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.
Try it: resample or not?
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?
A sample is 2, 4, 4, 7, 8. Which could be a bootstrap resample?
The sample 2, 4, 4, 7, 8 gives the resample 4, 7, 7, 2, 8. Find the resample mean.
Each time, a student draws 30 values without replacement from a sample of 30. What goes wrong?
A school surveys only students in its library about weekly screen time, then bootstraps 1000 times. Which is true?
Show answer
1. 40 2. The 25th and 975th 3. Each resample 4. It should be a random sample 5. 4, 4, 4, 2, 8. A resample has the same size, 5, and is drawn with replacement, so a value can repeat but only values from the sample appear. 6. 5.6. The resample adds to 28, and 28 ÷ 5 = 5.6. 7. Every resample has the same mean as the sample, because drawing all 30 without replacement just rebuilds the sample, so there is no spread to see. 8. The interval copies any bias in the library sample: the bootstrap only reuses the data it is given and cannot fix a poor 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.
Challenge
A tiny random sample has just three values: 3, 6 and 12, with mean 7. Bootstrap resamples of size 3 are drawn with replacement, keeping track of the order of the draws. (a) How many different ordered resamples are possible, and what is the probability that a resample has mean exactly 7? (b) Find the probability that a resample mean is above 7, and the probability that it is below 7. (c) Which whole number from 3 to 12 can never be a resample mean, and why?
Hint
Each of the 3 draws has 3 equally likely choices. For (a), ask which combinations of three values from 3, 6 and 12 add up to 21.
Answer
(a) 27 resamples; only the 6 orderings of 3, 6, 12 have mean 7, so the probability is 627 = 29. (b) Above 7: 1027. Below 7: 1127. (c) 11 is impossible: it needs a total of 33, and no three values from 3, 6 and 12 add to 33.
Step by step
- Each draw can be 3, 6 or 12, and the value is put back each time, so there are 3 × 3 × 3 = 27 equally likely ordered resamples.
- A mean of 7 needs a total of 21. The only way is one each of 3, 6 and 12, which can be drawn in 3 × 2 × 1 = 6 orders. So the chance is 627 = 29: most resamples are not just the sample shuffled.
- Listing the totals of all 27 resamples: 10 have a total above 21 and 11 have a total below 21. So 1027 above and 1127 below.
- The possible means are 3, 4, 5, 6, 7, 8, 9, 10 and 12. A mean of 11 needs a total of 33. Two 12s give 24, and adding 3 or 6 gives 27 or 30, while three 12s give 36. So 33 cannot happen.
- This shows why the bootstrap needs a decent sample: with only three values the resample means are lumpy and gappy, not a smooth spread.
Full working
- 3 × 3 × 3 = 27three draws, three choices each
- mean 7 needs total 21 = 3 + 6 + 12the only combination
- 3 × 2 × 1 = 6 ordersP(mean = 7) = 627 = 29
- totals above 21: 10, below 21: 11count all 27
- total 33: 24 + 3 = 27, 24 + 6 = 30, 3633 impossible
- 27; 29; above 1027, below 1127; 11 is impossible
A student has a random sample of 30 Year 13 students' weekly screen times, with mean 50 hours. When she codes her bootstrap she makes a mistake: each resample has only 10 values, drawn with replacement. Her 95% bootstrap interval for the population mean is 40.2 to 59.8 hours. (a) Is her interval too wide or too narrow? Estimate the interval she should have got. (b) A classmate makes a different mistake: resamples of 30, drawn without replacement. What interval does he get, and why? (c) Explain why the correct resample size is 30, not 10 and not 1000.
Hint
The spread of resample means depends on how many values go into each mean, through √(size). Compare √10 with √30.
Answer
(a) Too wide, by a factor of √3 ≈ 1.73. The correct interval is about 44.3 to 55.7 hours. (b) 50 to 50: every resample is the same 30 values, so every mean is 50. (c) The resamples imitate new random samples of the size actually taken, which is 30, so they show how much a mean of 30 values varies.
Step by step
- A mean of fewer values varies more. The spread of resample means is proportional to 1 ÷ √(resample size).
- Her resamples have 10 values, but they should have 30. 30 is 3 times 10, so the correct spread is her spread divided by √3 ≈ 1.732.
- Her interval is 50 ± 9.8. Dividing 9.8 by √3 gives about 5.66, so the correct interval is about 44.3 to 55.7 hours.
- Drawing 30 from 30 without replacement just picks all 30 values in a new order. Every mean is 50, so his interval is 50 to 50, with no width at all.
- The bootstrap asks: if I took another random sample of this size, how much might the mean change? The size taken was 30, so each resample must have 30 values, with replacement.
Full working
- spread ∝ 1√(resample size)means of fewer values vary more
- her half-width = 59.8 − 50 = 9.8interval centred on 50
- correct half-width = 9.8 ÷ √(30 ÷ 10) = 9.8 ÷ √3 = 5.66
- 50 − 5.66 = 44.34, 50 + 5.66 = 55.66
- without replacement: every resample mean = 50same 30 values
- about 44.3 to 55.7 hours; the classmate gets 50 to 50
A random sample of 10 members of a Nelson library gives the number of books each borrowed last month. Nine members borrowed 2 books and one borrowed 32. (a) Show that every bootstrap resample mean must be one of 2, 5, 8, 11, ... (b) Find the probability that a resample mean is exactly 2. (c) Estimate the 95% bootstrap interval for the population mean from 1000 resamples, and explain why this interval is a poor guide to the mean number of books borrowed by all members.
Hint
In a resample of 10, let k be the number of times the 32 is drawn. Each draw picks the 32 with probability 0.1, independently, so k has a binomial distribution.
Answer
(a) With k copies of 32 and 10 − k copies of 2, the mean is 2 + 3k. (b) 0.9¹⁰ ≈ 0.349. (c) About 2 to 11 books. It is a poor guide because everything hinges on one heavy borrower: the resamples can only rearrange the 10 values, so the interval reflects how often one value is redrawn, not what the population is like.
Step by step
- A resample has 10 values, each 2 or 32. If k of them are 32, the total is 32k + 2(10 − k) = 20 + 30k, so the mean is 2 + 3k: 2, 5, 8, 11 and so on.
- Each draw picks the 32 with probability 110, independently, so k is binomial with n = 10 and p = 0.1. A mean of exactly 2 needs k = 0, with probability 0.9¹⁰ ≈ 0.349.
- So about 349 of 1000 resample means are exactly 2. The bottom 2.5%, the lowest 25 means, are all 2, so the lower limit is 2.
- Cumulative probabilities: k ≤ 2 gives 0.930 and k ≤ 3 gives 0.987. The 975th sorted mean falls where k = 3, so the upper limit is 2 + 9 = 11.
- The interval runs from 2 to 11, a huge range set by how often one member is redrawn. The resamples can never contain values like 5 or 10 books that real members may borrow.
- With 10 values and one extreme one, the sample is too small and too lumpy for the bootstrap to imitate new samples well. A larger random sample is needed.
Full working
- mean = (32k + 2(10 − k)) ÷ 10 = 2 + 3kk = number of 32s
- k ~ binomial(10, 0.1)each draw is 32 with probability 0.1
- P(k = 0) = 0.9¹⁰ = 0.349mean exactly 2
- P(k ≤ 2) = 0.930, P(k ≤ 3) = 0.98797.5% falls at k = 3
- interval ≈ 2 to 2 + 3 × 3 = 11
- P(mean = 2) ≈ 0.349; interval about 2 to 11 books, driven by one value
Report a mistake
More in AS 91582
Is your child on track?
Take the free placement test


