Skip to content
Tactiverge

School/✦ Research Engineer/Week 34

The bootstrap: uncertainty from your own data

Your metric is a median of skewed settling times. There is no neat formula for its standard error. Can the data tell you instead?

About 45 min · 3 goals · Checked by automated tests

1.Why should I care?

Real engineering metrics are often medians, percentiles, ratios or success rates with no tidy SE formula. The bootstrap gives you an honest interval for almost any statistic, using only computation you already know how to do.

  • ◇ Explain the bootstrap idea: resample the data with replacement and recompute the statistic.
  • ◇ Build a percentile confidence interval from bootstrap replicates.
  • ◇ State the bootstrap's assumptions and when it fails.

2.Discover

Do one resample and read the ×counts. Then +1000. Compare the bootstrap SE of the mean with the formula s/√n. Switch to the median: what does the histogram look like now? Reset with a new seed: how stable is the interval?

Loading the interactive…

Can't use the interactive? Read a description instead

The bootstrap resampler shows the original values, how many times each was drawn in the latest resample, and a histogram of resampled means or medians with the observed value and the 95% percentile interval marked. Buttons add 1, 100 or 1000 resamples.

3.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

Why must bootstrap resampling be WITH replacement?

4.Predict

When you resample 12 values with replacement, what typically happens?

Guess first. Being wrong here is how the surprise works.

5.Understand

Resample, recompute, repeat

Treat your sample as a stand-in for the population. Draw n values from it with replacement, compute the statistic, and repeat a thousand times. The histogram of results shows how uncertain the statistic is. For a mean it agrees closely with s/√n; for medians and ratios it gives answers formulas cannot.

Comparing two methods

For a difference, resample each group separately (or resample paired seeds together), compute the difference each time, and take the 2.5% and 97.5% quantiles. Record the bootstrap seed: bootstrap intervals are random too, and should be reproducible.

Where it fails

The bootstrap assumes runs are independent and the sample represents the population. With very small n (under about 10), heavy tails or dependent runs (time series), the interval can be too narrow. It never corrects a biased sample or a confounded design.

Explain it another way

Your data are a small mirror of the world. Shaking the mirror and looking again shows how much the picture could change.

Derivation: The bootstrap idea
  1. We want the sampling distribution of a statistic θ̂ (e.g. the median): how it would vary over new datasets of size n.

  2. We cannot draw new datasets from the true population F.

  3. Plug-in principle: replace F by the empirical distribution F̂ that puts mass 1/n on each observed value.

  4. Drawing n values from F̂ = resampling the data with replacement. Compute θ̂* on each resample.

  5. Repeat B times (B ≈ 1000–10,000). The spread of the θ̂* estimates the spread of θ̂: SE_boot = SD(θ̂*).

  6. Percentile interval: the 2.5% and 97.5% quantiles of θ̂*. Assumes the sample represents the population; it cannot fix bias or a tiny n.

Worked example 1

1000 bootstrap medians, sorted: the 25th is 2.18 s and the 975th is 2.52 s. Interval?

Percentile 95% CI ≈ [2.18, 2.52] s (the 2.5% and 97.5% quantiles of 1000 values sit near positions 25 and 975).

Common mix-ups

  • The bootstrap creates extra data, so small samples become reliable.
    ✓ It only reuses the data you have; it estimates uncertainty, it cannot reduce it or fix a biased sample.

6.Watch

→ Follow the three steps (resample, compute, repeat) and notice what the video says the histogram is for.

Builds the bootstrap from scratch: resample your own data with replacement, recompute the statistic, and read its spread as uncertainty.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

The video is optional: everything you need is also in the lesson text and the interactive.

7.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 2

With B = 2000 sorted bootstrap values, roughly which position gives the lower bound of a 95% percentile interval?

Practice 3

When is a bootstrap interval least trustworthy?

Practice 4 · a fresh version every time

You run n = 64 trials and measure grasp force error. The sample standard deviation is s = 0.3 N. What is the standard error of the mean, in N?

N

Practice 5

Should you record the bootstrap's random seed?

8.Apply it

Write a bootstrap function for your capstone's primary metric difference (with a recorded seed). Check it against the formula SE on a mean, then use it for your real metric.

9.Reflect

Concepts: Statistical inference: intervals, effect sizes and p-values · Probability and Monte Carlo simulation