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
Files
- data.py (12 lines)
- intervals.py (19 lines)
- run.py (39 lines)
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
- https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.bootstrap.html
- https://en.wikipedia.org/wiki/Bootstrapping_(statistics)
- https://en.wikipedia.org/wiki/Student%27s_t-test
- https://pypi.org/pypi/numpy/json
- https://pypi.org/pypi/scipy/json
- https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm
Learning IT by Example.