Skip to main content

bootstrap2 - confidence intervals made easy

bootstrap2 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.

It is a maintained continuation of the original bootstrapped library (renamed and refreshed for modern Python packaging).


Table of Contents


1. Motivating example - A/B test

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 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!

2. The gist - mean of a sample

Given a sample of data, we can generate a bunch of new samples by 're-sampling' from what we have gathered. We calculate the mean for each generated sample. We can use the means from the generated samples to understand the variation in the larger population and can construct error bars for the true mean.

3. Benefits

  • Efficient computation of confidence intervals
  • Functions to handle single populations and A/B tests
  • Functions to understand statistical power
  • Multithreaded support to speed up bootstrap computations
  • Dense and sparse array support

4. Example usage

import numpy as np
import bootstrap2.bootstrap as bs
import bootstrap2.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))
# Output: 99.55    (98.95, 100.16)

print(bs.bootstrap(samples, stat_func=bs_stats.std))
# Output: 9.87    (9.45, 10.30)

4.1. Extended examples

5. Requirements

bootstrap2 requires Python 3.10+, numpy, scipy, matplotlib, and pandas.

6. Installation

pip install bootstrap2

7. How bootstrap2 works

bootstrap2 provides pivotal (aka empirical) based confidence intervals based on bootstrap re-sampling with replacement. The percentile method is also available.

For more information please see:

  1. Bootstrap confidence intervals (good intro)
  2. An introduction to Bootstrap Methods
  3. The Bootstrap, Advanced Data Analysis
  4. When the bootstrap doesn't work
  5. (book) An Introduction to the Bootstrap
  6. (book) Bootstrap Methods and their Application

See CONTRIBUTING.md for how to help out.

8. Contributors

Spencer Beecher, Don van der Drift, David Martin, Lindsay Vass, Sergey Goder, Benedict Lim, and Matt Langner.

Special thanks to Eytan Bakshy.

9. License

bootstrap2 is BSD-licensed (BSD-3-Clause), the same license as the original bootstrapped library; see LICENSE. An additional patent grant from the original project is in PATENTS.

The example notebooks in examples/ are derived from the original project's examples and remain under LICENSE-examples, which permits non-commercial testing and evaluation only.

Metadata

Release files for bootstrap2 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bootstrap2 0.1.0
File Size Uploaded
bootstrap2-0.1.0.tar.gz 18.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bootstrap2 0.1.0
File Interpreter ABI Platform
bootstrap2-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / bootstrap2-0.1.0.tar.gz

Download URL bootstrap2-0.1.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8f07fc6894308d63b00a0fdeea257ad24e374368d2d582faf5d01884a45cd10e
BLAKE2b-256 checksum
How to use checksums
8bb70c8572b920783a5688c70e3ad66f813f990424dc6e1b6245b294be2b090e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / bootstrap2-0.1.0-py3-none-any.whl

Download URL bootstrap2-0.1.0-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3721946c7fc9ee81da2e2a382f86cf123a74549a8ab498d97abf99c9872aaf97
BLAKE2b-256 checksum
How to use checksums
ce9afac95ef4694a4f1c3ca148e426f99ff83be9b2c710a7915d7b5cd008a750
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page