Real Data Case Studies
Seeded Bootstrap Confidence Interval on a Real Sample
bootstrap-mean-small (ch06) shows the bootstrap mechanism on a 5-value
pinned sample — too small for the resampling distribution to mean much.
Here the same idea runs on line A's real 40-batch defect-rate sample via
lmda bootstrap, with a fixed seed so the resampled confidence interval is
byte-for-byte reproducible, not just conceptually repeatable.
The real dataset
data/defect_rate_line_a.csv is line A's 40 batches from the same
manufacturing dataset as anova-defect-rate-by-line, filtered down to
line == "A" (a plain row subset — every value is copied unchanged from the
committed source file, nothing recomputed).
| line | batch | defect_rate |
|---|---|---|
| A | 1 | 0.09 |
| A | 2 | 0.025 |
| A | 3 | 0.055 |
| A | 4 | 0.06 |
| A | 5 | 0.035 |
The sample mean is exactly the mean value ANOVA reported for group A:
0.046875 over 40 batches. The question here is different from ANOVA's: not
"do groups differ" but "how much would this mean itself wobble if we'd
drawn a different 40 batches from the same process?"
Percentile bootstrap
lmda bootstrap resamples the 40 defect-rate values with replacement 5000
times, recomputes the mean each time, and reports the 2.5th/97.5th
percentiles of that resampled distribution as a 95% confidence interval.
--seed fixes the resampling draws so the result is exactly reproducible,
not merely "close every time":
lmda bootstrap data/defect_rate_line_a.csv --column defect_rate --stat mean --reps 5000 --confidence 0.95 --seed 20260726 --format json
{
"ci_lower": 0.04025,
"ci_upper": 0.054125,
"column": "defect_rate",
"confidence": 0.95,
"estimate": 0.046875,
"n": 40,
"reps": 5000,
"seed": 20260726,
"stat": "mean"
}
estimate matches the plain sample mean (0.046875); ci_lower/ci_upper
bound the plausible range for the population mean this sample was drawn
from, at 95% confidence — noticeably wider than the point estimate alone
suggests, which is the whole reason to report an interval instead of a bare
mean.
Honesty
The resampling and percentile computation are exact and the seed makes the
interval exactly reproducible — this is a genuine confidence interval for
line A's mean defect rate, not a demonstration, since n=40 is an adequate
bootstrap sample size (unlike bootstrap-mean-small's n=5). Two scope
limits still apply: (1) the bootstrap only resamples these 40 batches, so
it captures batch-to-batch sampling variability but not any bias in how
these particular 40 batches were selected or measured; (2) as with the other
lessons in this chapter, the dataset is a realistic simulated manufacturing
process (lmda's case-study-1 worked example), so this interval describes the
simulated data-generating process, not an actual production line.
Implementation notes
data/defect_rate_line_a.csvis a plain row filter ofanova-defect-rate-by-line/data/defect_rate.csv(line == "A", all 40 rows, no other column touched) — a reviewer can diff the two files by eye.- The bootstrap command above is re-run against the committed CSV on every
validate_source.pypass and must byte-for-byte match the checked-inoutputs/bootstrap-line-a-mean.json, including the reportedestimateand interval bounds — the fixed--seedis what makes that byte-for-byte match possible for a randomized method. - Cross-reference:
bootstrap-mean-small(ch06) for the tiny-sample mechanism trace;standard-error(ch06) for the closed-form analytic alternative to a resampled interval.