learning-it by example

Back to the video

Confidence Intervals by Simulation: Bootstrap vs Formula

A 95% bootstrap interval from 10 made-up values caught the true mean 863 times in 1000.

Video #199 ยท Machine learning and data science

Steps in the video

  1. 0:00 A 95% interval that caught the mean 863 times in 1000
  2. 0:28 The idea
  3. 1:01 Setup
  4. 1:19 A made-up population
  5. 1:41 The formula
  6. 2:03 The bootstrap
  7. 2:58 Count the hits
  8. 3:46 What each assumes
  9. 4:17 What this does not show
  10. 4:49 Mistakes to avoid
  11. 5:22 My take and next steps
  12. 5:49 Recap

Files

  • data.py (12 lines)
  • intervals.py (19 lines)
  • run.py (39 lines)

Download the code (zip)

Tested with

Python 3.12.15 | numpy==2.5.4, scikit-learn==1.9.1, scipy==1.18.1, joblib==1.6.0, narwhals==2.27.1, threadpoolctl==3.7.0, cloudpickle==3.1.2

What this does not show

Made-up skewed data, 1000 tries per sample size, and only the plain percentile bootstrap (no BCa).

Sources

Learning IT by Example.