Read-only time-series bootstrap server: diagnose a series and compute confidence intervals.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent โ or use 1-click editor setup below.
๐ก Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
tsbootstrap exposes one typed entry point, bootstrap, configured with a method
specification. The same call works for every method.
Choose a method spec for the structure you need (block lengths default to the automatic Politis-White selection):
Inputs can be NumPy arrays, lists, or pandas / Polars DataFrames and Series. The
result is a BootstrapResult carrying the samples, provenance metadata, and
out-of-bag / in-bag primitives. For the sktime ecosystem, the same methods are
also available as estimator classes (MovingBlockBootstrap, ARResidualBootstrap,
SieveBootstrap, and the rest) under tsbootstrap.adapters.
The uq layer turns resampled series into prediction intervals. forecast_intervals
gives forward forecast bands for an AR model; EnbPIEnsemble produces out-of-bag
prediction intervals for an sklearn-style regressor, with calibrators for stationary,
volatility-clustered, and drifting data (static, sliding window, and the adaptive ACI,
AgACI, and NexCP schemes); and bootstrap_reduce streams a per-replicate statistic so
calibration scales to large replicate counts without holding every path in memory.
For a confidence interval on a statistic of one series, conf_int runs the bootstrap
and reads the interval in one call:
The conformal pieces (EnbPIEnsemble and the calibrators) need the uq extra
(scikit-learn). The interactive
tutorial gallery
works through every method on real and synthetic data, including a "which bootstrap
should I use?" decision guide.
tsbootstrap ships a read-only Model Context Protocol
server so an MCP client (an LLM agent, an IDE) can diagnose a short series and compute a
bootstrap confidence interval without writing any Python. Run it with no install step:
It speaks the stdio transport and exposes exactly two read-only tools:
diagnose_series: serial-dependence and stationarity diagnostics, a recommended
Politis-White block length, and the bootstrap methods the server supports for the series.bootstrap_confidence_interval: a percentile confidence interval for the mean, median,
std, or variance, using an i.i.d. or block bootstrap.Both tools accept at most 500 observations and run at most 500 replicates. For larger series, model-based methods, or the uncertainty layer, use the library directly in a local script.
Requires Python 3.10 or higher.
The model-based methods import statsmodels lazily and raise a clear install hint if
the models extra is missing.

Left: speedup of the compiled reduce path over the arch library on the four overlapping methods. Right: peak memory before and after on the two headline reduce workloads (baseline = materialize every path, then reduce). The figure and the table below are generated from the committed benchmark data in benchmarks/results/; regenerate with python benchmarks/plot_launch.py.
tsbootstrap ships an optional compiled backend (backend="compiled", via the
[accel] extra) that is faster than the arch
library on every overlapping resampling method. The table below is the speedup of
the streaming reduce path over arch.apply on an 8-core CPU (higher is better),
read from benchmarks/results/vs_arch_ccx33_2026-07-11_settled.json
(the settled-min statistic; methodology in benchmarks/README.md).
| Method | n=200, B=999 | n=200, B=10000 | n=2000, B=999 | n=2000, B=10000 |
|---|---|---|---|---|
| IID | 15x | 19x | 4.7x | 8.6x |
| MovingBlock | 38x | 61x | 9.8x | 26x |
| CircularBlock | 41x | 66x | 13x | 33x |
| StationaryBlock | 19x | 24x | 6.8x | 12x |
Read these as sustained gains of roughly 4.7x to 33x on the larger n=2000
workloads; the very large small-n multiples come from arch's per-replicate
Python callback in bs.apply, whose overhead dominates its runtime when each
resample is cheap, so they measure that overhead as much as the compiled kernel.
The compiled reduce fuses index build, gather, and reduction into one pass, so
peak memory stays flat in the number of replicates: at n=2000 the streaming
reduce holds about 20 MB at B=50000 where materializing every replicate takes
about 1.94 GB (roughly 96x lighter), from
benchmarks/results/membench_2026-07-04.json.
The multivariate and ragged-panel reduce
paths have no equivalent in arch. The panel reduce
(bootstrap_reduce_panel) returns the full per-series bootstrap distribution
of the statistic (n_bootstraps x num_series), so quantile and tail workflows
on an estimator are served directly with no replicate tensor. Use the
materializing path only when the workflow consumes the resampled paths
themselves. Full methodology,
single-threaded numbers, and the reproduction script are in
benchmarks/README.md.
Deep dives on the statistics and engineering behind the library, with worked examples and animations:
Package layout:
| Area | Module(s) | Role |
|---|---|---|
| Public API | api.py, methods.py, results.py, errors.py, diagnostics.py | the bootstrap() entry point, typed method specs, structured results, error taxonomy, and diagnose() |
| Infrastructure | rng.py, validation.py, dispatch.py, metadata.py | deterministic RNG contract, input coercion (incl. the narwhals DataFrame boundary), spec to executor dispatch, method metadata |
| Block methods | block/ | vectorized index kernels, true Politis-Romano stationary, energy-normalized tapering, PWSD block length, OOB primitives |
| Model methods | model/, engines/ | model fitting, stability guards, and recursive AR/ARMA/VAR simulation |
| Uncertainty quantification | uq/ | classical confidence intervals (percentile, basic, studentized, BCa) via conf_int, EnbPI prediction intervals, the static / sliding-window / ACI / AgACI / NexCP calibrators, and AR forecast intervals |
| Ecosystem | adapters/ | skbase / sktime estimator classes over the functional core |
The full, living roadmap is issue #181. Highlights:
Near term:
Candidate methods (good first issues):
Distributed execution (Dask / Spark / Ray), an async layer, and a string-keyed
factory were considered and deliberately left out. The library is a CPU-bound,
single-process toolkit.
See our good first issues for getting started.
Fork the tsbootstrap repository
Clone the fork to local:
uv creates an isolated virtual environment from uv.lock and editable-installs the
package, so changes to the package are reflected in your environment automatically. Run
tools through the environment with uv run (for example uv run pytest).
Install the pre-commit hooks:
The hooks run ruff, formatting, and the other code-quality checks on each commit.
Verify the installation:
This prints the installed version.
new-feature-branch or bugfix-issue-123).To run all tests, in your developer environment, run:
The sktime adapter classes can be validated with sktime's estimator checks:
This project is licensed under the โน๏ธ MIT License. See the LICENSE file for additional info.
Contributors:
This project follows the all-contributors specification. Contributions of any kind welcome!
tsbootstrap implements bootstrapping methods for time series data. It generates resampled copies of univariate and multivariate series that preserve their chronological order and dependence structure.
Traditional bootstrap methods resample observations independently, which breaks the dependence in a time series: each observation usually depends on the ones before it. Time series bootstraps resample while preserving chronological order and correlation, so the resulting uncertainty estimates stay valid under that dependence.
tsbootstrap resamples either the observations directly (i.i.d. and block methods) or
the innovations of a fitted model (residual and sieve methods), respecting the
chronological order and dependence structure of the data.
Block methods resample blocks of consecutive observations to preserve short-range dependence. The block length defaults to the automatic Politis-White (2004) selection.
MovingBlock): overlapping fixed-length blocks (Kunsch 1989).CircularBlock): blocks wrap around the series end (Politis-Romano 1992).StationaryBlock): geometric block lengths with independent uniform
restart points (Politis-Romano 1994).NonOverlappingBlock): disjoint blocks (Carlstein 1986).TaperedBlock(window=...)): blocks weighted by an energy-normalized
window (Bartlett, Blackman, Hamming, Hann, or Tukey; Paparoditis-Politis 2001).For dependent data with a good model fit, ResidualBootstrap(model=...) regenerates the
series recursively from the fitted dynamics and resampled, centered innovations (not
fitted + residuals). Supported models: AR, ARIMA, and VAR (multivariate). A
non-stationary fit is refused (or skipped, per stability_policy) rather than producing
explosive paths.
SieveAR selects an autoregressive order on the original series, then runs the AR recursion;
suited to data with autoregressive structure.
The innovation argument on ResidualBootstrap and SieveAR controls how the centered
residuals are resampled. It defaults to IID (uniform resampling); two wild resamplers relax
the exchangeability that assumes.
Wild(distribution=...)): multiplies each residual in place by a mean-zero,
unit-variance draw (e*_t = v_t * e_hat_t), keeping its time position and magnitude, so it
stays valid under conditional heteroskedasticity (Wu 1986; Liu 1988; Rademacher default per
Davidson-Flachaire 2008).BlockWild(block_length=...)): holds one multiplier constant across each
block of residuals, so serial dependence left by a misspecified mean survives the resampling
(piecewise-constant dependent wild bootstrap, Shao 2010).Both require the host model's burn_in=0 and initial="fixed" defaults so the multipliers
align one-to-one with the residuals.
Markov resampling, the distribution bootstrap, GARCH/volatility models, and frequency-domain / seasonal block methods are planned for a future version. The statistic-preserving method has been removed.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/tsbootstrap)<a href="https://allmcps.com/mcp/tsbootstrap"><img src="https://allmcps.com/api/badge/tsbootstrap?style=directory" alt="Tsbootstrap on AllMCPs" /></a>