Skip to main content

Resampling-based inference in Python

Project description

https://img.shields.io/pypi/v/resample.svg https://img.shields.io/conda/vn/conda-forge/resample.svg https://github.com/resample-project/resample/actions/workflows/test.yml/badge.svg https://coveralls.io/repos/github/resample-project/resample/badge.svg https://readthedocs.org/projects/resample/badge/?version=stable https://img.shields.io/pypi/l/resample https://zenodo.org/badge/145776396.svg

Link to full documentation

Resampling-based inference in Python based on data resampling and permutation.

This package was created by Daniel Saxton and is now maintained by Hans Dembinski.

Features

  • Bootstrap resampling: ordinary or balanced with optional stratification

  • Extended bootstrap resampling: also varies sample size

  • Parametric resampling: Gaussian, Poisson, gamma, etc.)

  • Jackknife estimates of bias and variance of any estimator

  • Compute bootstrap confidence intervals (percentile or BCa) for any estimator

  • Permutation-based variants of traditional statistical tests (USP test of independence and others)

  • Tools for working with empirical distributions (CDF, quantile, etc.)

  • Depends only on numpy and scipy

Example

We bootstrap the uncertainty of the arithmetic mean, an estimator for the expectation. In this case, we know the formula to compute this uncertainty and can compare it to the bootstrap result. More complex examples can be found in the documentation.

from resample.bootstrap import variance
import numpy as np

# data
d = [1, 2, 6, 3, 5]

# this call is all you need
stdev_of_mean = variance(np.mean, d) ** 0.5

print(f"bootstrap {stdev_of_mean:.2f}")
print(f"exact {np.std(d) / len(d) ** 0.5:.2f}")
# bootstrap 0.82
# exact 0.83

The amazing thing is that the bootstrap works as well for arbitrarily complex estimators. The bootstrap often provides good results even when the sample size is small.

Installation

You can install with pip.

pip install resample

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

resample-1.9.0.tar.gz (487.5 kB view details)

Uploaded Source

Built Distribution

resample-1.9.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file resample-1.9.0.tar.gz.

File metadata

  • Download URL: resample-1.9.0.tar.gz
  • Upload date:
  • Size: 487.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for resample-1.9.0.tar.gz
Algorithm Hash digest
SHA256 108d9edf2e3e23027d542a4c92ef3c71ada7284da86ce1283f7ff741fb01cc3f
MD5 ab5e4498fc317e53b948bc569b4718d6
BLAKE2b-256 8b4bcc6ee52baa8ebb4957fcf515a706f761c51ac06021afc7692a82277f559c

See more details on using hashes here.

File details

Details for the file resample-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: resample-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for resample-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e1a20f0c473fee96e97b5f6d3c8502c02097d39940137af55f096d4eaeffd75
MD5 67370f568496f21422c0912490b41ddd
BLAKE2b-256 771c1d79034f7101a66d8671f5f50159774015d8186f7902e223ae93073a61c4

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