bootstrapped is a Python library that allows you to build confidence intervals from data. This is useful in a variety of contexts - including during ad-hoc a/b test analysis.
Imagine we own a website and think changing the color of a 'subscribe' button will improve signups. One method to measure the improvement is to conduct an A/B test where we show 50% of people the old version and 50% of the people the new version. We can use a method called 'the bootstrap' to understand how much the button color improves responses and give us the error bars associated with the test - this will give us lower and upper bounds on how good we should expect the change to be!
- Efficient computation of confidence intervals
- Functions to handle single populations and a/b tests
- Functions to understand statistical power
import numpy as np
import bootstrapped.bootstrap as bs
import bootstrapped.stats_functions as bs_stats
mean = 100
stdev = 10
population = np.random.normal(loc=mean, scale=stdev, size=50000)
# take 1k 'samples' from the larger population
samples = population[:1000]
print(bs.bootstrap(samples, stat_func=bs_stats.mean))
>> 100.08 (99.46, 100.69)
print(bs.bootstrap(samples, stat_func=bs_stats.std))
>> 9.49 (9.92, 10.36)
- Bootstrap Intro
- Bootstrap A/B Testing
- More notebooks can be found in the examples/ directory
bootstrapped requires numpy. The power analysis functions require matplotlib and pandas.
# clone bootstrapped
cd bootstrapped
pip install -r requirements.txt
python setup.py install
tldr - Percentile based confidence intervals based on bootstrap re-sampling with replacement.
Bootstrapped generates confidence intervals given input data by:
- Generating a large number of samples from the input (re-sampling)
- For each re-sample, calculate the mean (or whatever statistic you care about)
- Of these results, calculate the 2.5th and 97.5 percentiles (default range)
- Use this as the 95% confidence interval
For more information please see:
- Bootstrap confidence intervals (good intro)
- An introduction to Bootstrap Methods
- The Bootstrap, Advanced Data Analysis
- When the bootstrap dosen't work
- (book) An Introduction to the Bootstrap
- (book) Bootstrap Methods and their Application
See the CONTRIBUTING file for how to help out.
Spencer Beecher, Don van der Drift, David Martin, Lindsay Vass, Sergey Goder, Benedict Lim, and Matt Langner.
Special thanks to Eytan Bakshy.
bootstrapped is BSD-licensed. We also provide an additional patent grant.