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.10.2.tar.gz (632.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resample-1.10.2-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: resample-1.10.2.tar.gz
  • Upload date:
  • Size: 632.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for resample-1.10.2.tar.gz
Algorithm Hash digest
SHA256 a61821d9456517305892df16f935d2712ffc7d05633ecb1c9d744bdc9f672c31
MD5 19cd7c645ac67dd79574c7612eb8d9e1
BLAKE2b-256 4490ccdebd34dd56e5f67249391aba6e800bf6be58e907db17fcdf8c11e9891d

See more details on using hashes here.

Provenance

The following attestation bundles were made for resample-1.10.2.tar.gz:

Publisher: release.yml on scikit-hep/resample

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: resample-1.10.2-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for resample-1.10.2-py3-none-any.whl
Algorithm Hash digest
SHA256 868aec501a5eb0907fcc30dc69bd66f3dc23850424600bbbb1f3206ff7767932
MD5 594062e4c3780b492057676597382839
BLAKE2b-256 75e60032a232976c58c452db220cde00e2ca91516f25de48b6c0786fe82454f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for resample-1.10.2-py3-none-any.whl:

Publisher: release.yml on scikit-hep/resample

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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