Skip to main content

Production-grade uncertainty estimation for Python.

Project description

bootstrapx

Production-grade uncertainty estimation for Python.

CI PyPI Python License: MIT Docs

14 bootstrap methods · Numba JIT · Optional CUDA GPU · Memory-safe batching


Why bootstrapx?

scipy.stats.bootstrap supports only 3 CI methods and has no time-series support. The R boot package is comprehensive but not accessible from Python. bootstrapx bridges this gap with 14 methods, Numba acceleration, and a clean API.

Feature scipy R boot bootstrapx
BCa interval
Studentized (bootstrap-t)
Poisson / Bernoulli weights
Time-series (MBB, CBB, Stationary, Sieve, Tapered, Wild) Partial
Cluster / Stratified Partial
Numba JIT N/A
CUDA GPU
Generator batching (constant memory)

Installation

pip install bootstrapx

# With GPU
pip install "bootstrapx[cuda]"

Quick Start

import numpy as np
from bootstrapx import bootstrap

data = np.random.default_rng(42).normal(5, 2, size=200)

result = bootstrap(data, np.mean)
print(result)
# BootstrapResult(method='bca', theta_hat=4.94, se=0.13, CI=[4.70, 5.19])

Performance

bootstrapx is significantly faster than scipy.stats.bootstrap for large datasets:

N Method Scipy Bootstrapx Speedup
5,000 BCa 0.80s 0.27s 3.0x
50,000 Percentile 7.29s 2.01s 3.6x
100,000 Percentile 54.34s 3.99s 13.6x

Benchmark on Apple M1, Python 3.12. See Benchmarks for details.


Coverage Accuracy

Monte Carlo simulation ($N=1000$, 500 runs) confirms correct statistical coverage:

Distribution BCa Coverage (Nominal 95%)
Normal 94.8%
Skewed (Exponential) 95.0%
Heavy-Tailed (t-dist) 94.0%

Documentation

📖 Full docs: artyerokhin.github.io/bootstrapx


Contributing

git clone https://github.com/artyerokhin/bootstrapx.git
cd bootstrapx
pip install -e ".[dev,docs]"
pytest tests/ -v
mkdocs serve

License

MIT — see LICENSE.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

bootstrapx_lib-0.1.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file bootstrapx_lib-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bootstrapx_lib-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for bootstrapx_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e7c0e14492269c4e7ace8f30464210b688bd0a52fde6b7a34328ed49e119526d
MD5 dd7b8bb672b19fafacb9ac80eec77bdc
BLAKE2b-256 51a241d6bd8dc7fcf123a5e6ead4886094ae0db1bdbbad96307edd1ef25102a2

See more details on using hashes here.

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