Skip to main content

Implementations of the percentile based bootstrap - forked

Project description

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.

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!

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.

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

Example Usage

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)

Extended Examples

Requirements

bootstrapped requires numpy. The power analysis functions require matplotlib and pandas.

Installation

pip install bootstrapped

How bootstrapped works

bootstrapped 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 dosen’t work

  5. (book) An Introduction to the Bootstrap

  6. (book) Bootstrap Methods and their Application

See the CONTRIBUTING file for how to help out.

Contributors

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

Special thanks to Eytan Bakshy.

License

bootstrapped is BSD-licensed. We also provide an additional patent grant.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bootstrapped-ng-0.1.3.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

bootstrapped_ng-0.1.3-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file bootstrapped-ng-0.1.3.tar.gz.

File metadata

  • Download URL: bootstrapped-ng-0.1.3.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for bootstrapped-ng-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3aa255041f48ea459b97e1c9f2c942a9e8804dfa1b461d1a92b77d2f0a827c2f
MD5 f0f6c1d2602890a33960768bc285a373
BLAKE2b-256 dd558c414580810de530280a6f3c79d507a37655cc0c7245f6a3f12f7345cdd9

See more details on using hashes here.

File details

Details for the file bootstrapped_ng-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for bootstrapped_ng-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d47dfe48c64e8b0d524bd9aa41276dcea328cbec9d0ec7e12d1eca10eab61a0d
MD5 d952df6383f3023443394fa5f3edfe52
BLAKE2b-256 0a40c444fd223c31f4a9d3fb05fada17f15597fa01ef195ec6485c9f39320072

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page