Resampling-based inference in Python
Project description
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.)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file resample-1.8.1rc1.tar.gz
.
File metadata
- Download URL: resample-1.8.1rc1.tar.gz
- Upload date:
- Size: 389.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19f4d4ae40b607bbadb8e4757fb5cecdaa8a712c561c2cc33602364873f527ca |
|
MD5 | bf03da7f0e21f54c623e7890bbe8265a |
|
BLAKE2b-256 | 0dd42a3b4b4d10bbc8ddd8d6fc8cdf030adddff04003e42d73d93155a304418b |
File details
Details for the file resample-1.8.1rc1-py3-none-any.whl
.
File metadata
- Download URL: resample-1.8.1rc1-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 859089452df5d866378a03acc3004e20c6b9764f7198f15d74e89a5ceb90b3a6 |
|
MD5 | 6ebec3f490857434583b19f1807f95c7 |
|
BLAKE2b-256 | ddb2f17d83cceb64783b0e63144c86b61f97a2e4c1d6f3a9bebab047bcae329d |