
tsbootstrap
io.github.astrogilda由 GitHub 帳號 astrogilda 發布v0.7.3更新於 Oct 24, 2026
Read-only time-series bootstrap server: diagnose a series and compute confidence intervals.
概覽
唯讀的 MCP 伺服器,讓助理診斷時間序列並計算簡單統計量的自助法信賴區間。
- 可以做什麼
- 診斷序列:序列相關性與平穩性檢定、建議的 Politis-White 分塊長度,以及該序列支援的 bootstrap 方法。
- 用 i.i.d. 或分塊 bootstrap 計算平均數、中位數、標準差或變異數的百分位信賴區間。
- 兩個工具皆為唯讀,每次呼叫最多 500 筆觀測值與 500 次重抽樣。
- 適用情境
- 適合在不寫 Python 的情況下,為較短的時間序列快速取得考量相依結構的區間估計或方法建議。對於更長的序列、以模型為基礎的方法或預測區間,README 建議直接在指令稿中使用該程式庫。
- 執行需求
- 透過 stdio 在本機執行,使用 uvx 從帶 mcp 附加項的 tsbootstrap 套件啟動;需要 Python 3.10 或更高版本。未宣告驗證、環境變數或請求標頭。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 tsbootstrap,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Fast, dependence-aware uncertainty for one time series or ten thousand.
Block, model-based, and wild resampling; confidence and prediction intervals; fused statistics without replicate tensors. Explore the documentation.
[Markdown] [Python] [pytest] [actions]
[preprint] [pypi-version] [pypi-python-version] [All-time downloads (pepy.tech)] [github-license] [Build Status] [codecov] [DOI] [Launch tutorials on Binder] [Last Commit] [Issues] [Pull Requests] [Tag] [Ask DeepWiki] [Context7]tsbootstrap makes the sampling design explicit through typed method specifications,
assumption metadata, and replayable run metadata. Its optional compiled reducers
calculate statistics while generating resamples, and its panel API supports
unequal-length series.
Read the engineering behind these results in Count the bytes, not the FLOPs and Ten thousand series, one pass.
The speed numbers describe the compiled named-statistic reduce path; the
default NumPy backend, arbitrary Python statistics, materialized samples, and
single-thread execution have distinct performance profiles. See the
full benchmark grid for those paths. The arch bootstrap
module also offers independent-samples bootstrapping, and the broader arch
package includes econometric tools. Neither is covered by this four-method
comparison.
📒 Table of Contents
- 🚀 Getting Started
- ⚡ Performance
- 📚 Articles
- 🧩 Modules
- 🗺 Roadmap
- 🤝 Contributing
- 📄 License
- 📍 Time Series Bootstrapping Methods intro
- 👏 Contributors
🚀 Getting Started
🎮 Using tsbootstrap
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.
Uncertainty quantification
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.
MCP server
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.
📦 Installation
Requires Python 3.10 or higher.
AR, VAR, and sieve fitting use the core NumPy implementation. ARIMA imports
statsmodels lazily and requires the models extra.
⚡ Performance
[tsbootstrap: speedup over arch and peak-memory reduction]
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). On the measured mean-reduction workload it is faster than
arch.apply for each of the four shared
resampling methods. 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).
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-thread behavior, and the reproduction script are in
benchmarks/README.md.
📚 Articles
Deep dives on the statistics and engineering behind the library, with worked examples and animations:
- Your bootstrap is lying to you: why the ordinary i.i.d. bootstrap collapses on autocorrelated data (a nominal 90% interval that covers 49.6% of the time) and how block resampling repairs it.
- When your errors aren't equal: the wild bootstrap for heteroskedastic errors, and what a block-wild variant preserves.
- Count the bytes, not the FLOPs: the memory-wall engineering behind the compiled backend, with hardware-counter receipts.
- Ten thousand series, one pass: the panel benchmark, its separate time and memory baselines, and the ragged-panel design.
🧩 Modules
Package layout:
🗺 Roadmap
The full, living roadmap is issue #181. Highlights:
Near term:
- Out-of-sample forecast intervals for ARIMA and VAR (currently AR-only).
Candidate methods (good first issues):
- Generalized block (#104), local block (#105), and frequency-domain (#107) bootstraps.
- A GARCH / volatility residual bootstrap, and the smooth-kernel dependent-wild bootstrap.
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.
🤝 Contributing
See our good first issues for getting started.
Developer setup
-
Fork the tsbootstrap repository
-
Clone the fork to local:
- In the local repository root, sync the locked development environment with uv:
-
uv creates an isolated virtual environment from
uv.lockand editable-installs the package, so changes to the package are reflected in your environment automatically. Run tools through the environment withuv run(for exampleuv run pytest). -
Install the pre-commit hooks:
The hooks run ruff, formatting, and the other code-quality checks on each commit.
Verifying the Installation
Verify the installation:
This prints the installed version.
Contribution workflow
- Create a new branch with a descriptive name (e.g.,
new-feature-branchorbugfix-issue-123).
- Make changes to the project's codebase.
- Commit your changes to your local branch with a clear commit message that explains the changes you've made.
- Push your changes to your forked repository on GitHub using the following command
- Create a new pull request to the original project repository. In the pull request, describe the changes you've made and why they're necessary.
🧪 Running Tests
To run all tests, in your developer environment, run:
That runs in a single process. Add the pytest-xdist flags CI uses to run the suite in parallel, which is several times faster on a multi-core machine:
The sktime adapter classes can be validated with sktime's estimator checks:
Contribution guide
See CONTRIBUTING.md for details.
📄 License
This project is licensed under the ℹ️ MIT License. See the LICENSE file for additional info.
👏 Contributors
Contributors:
This project follows the all-contributors specification. Contributions of any kind welcome!
📍 Time Series Bootstrapping
tsbootstrap implements bootstrap methods for univariate and multivariate time
series. Block methods resample nearby observations together; model-based
methods simulate new paths from fitted dynamics.
Overview
An i.i.d. bootstrap breaks serial dependence by resampling individual observations. Block and model-based methods retain aspects of dependence under their stated assumptions. Interval coverage still depends on the data regime, the statistic, and the method choice; see the uncertainty guide.
Bootstrapping methodology
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 bootstrap
Block methods resample blocks of consecutive observations to preserve short-range dependence. The block length defaults to the automatic Politis-White (2004) selection.
- Moving block (
MovingBlock): overlapping fixed-length blocks (Kunsch 1989). - Circular block (
CircularBlock): blocks wrap around the series end (Politis-Romano 1992). - Stationary block (
StationaryBlock): geometric block lengths with independent uniform restart points (Politis-Romano 1994). - Non-overlapping block (
NonOverlappingBlock): disjoint blocks (Carlstein 1986). - Tapered block (
TaperedBlock(window=...)): blocks weighted by an energy-normalized window (Bartlett, Blackman, Hamming, Hann, or Tukey; Paparoditis-Politis 2001).
Residual bootstrap
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.
Sieve bootstrap
SieveAR selects an autoregressive order on the original series, then runs the AR recursion;
suited to data with autoregressive structure.
Innovation resamplers
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 (
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). - Block-wild (
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.
Deferred to a later release
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.
來源:README.md,提交 2dd5236
工具
0版本歷史
2- v0.7.3最新Sep 29, 2026
- v0.7.2Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分