thepragmaticquant.com

tsbootstrap

A time series bootstrap library for Python that resamples while preserving the dependence a plain bootstrap destroys, with conformal uncertainty.

Most bootstrap tutorials quietly assume your observations are independent. Time series are not, and that assumption is exactly where the confidence intervals start lying.

The ordinary bootstrap resamples observations at random. On a time series that shuffles away the very thing you care about: yesterday's value tells you something about today's, and once you break that link the resampled series looks nothing like the real one. The standard errors it hands back are too small, and nothing warns you. tsbootstrap is a time series bootstrap library for Python that resamples while keeping the dependence intact, using the methods the statistics literature actually recommends: block, residual, sieve, and wild resampling, with a conformal layer for prediction intervals on top.

This is a curriculum, not a feature tour. Each article takes one mistake people make when they bootstrap dependent data, shows it failing on real numbers, and then shows the method that fixes it. tsbootstrap is the worked example throughout, but the lessons are about the statistics and the engineering, not the package. You can read any piece on its own; read them in order and they build.

They fall into three tracks. The statistics track answers which resampler survives which broken assumption, and why no single one is best. The engineering track is about scale and trust: how to run millions of replicates without materializing them all in memory, and how to prove the code does what the math says. The adoption track is the honest comparison with what already exists, a library that can tell you when not to use it, and a server your coding agent can call directly.

The library ships today; the series is being written. Start with whichever failure you have hit yourself, or begin at the top and follow the thread.

last substantively updated: July 6, 2026

Drag the block length. At L = 1 the resample shreds the series to i.i.d. noise and the interval collapses; grow L and the wave structure — and an honest standard error — survive.

original series · AR(1), phi 0.7, n 200

one moving-block resample · L = 10

L = 10 · bootstrap SE of the mean = 0.171 analytic truth = 0.236
A toy on a seeded series: SE from B = 200 quick replicates so the slider stays live; the articles' numbers use B = 999 and 2,000-run coverage studies.

statistics

engineering