telescopic
Unbiased Markov chain Monte Carlo with coupled chains and telescoping sums.
telescopic runs pairs of coupled Markov chains until they meet, and turns each pair into an exactly unbiased estimate of expectations under the target distribution (Glynn & Rhee 2014; Jacob, O'Leary & Atchadé 2020). Averages over independent pairs come with error bars that are valid as the number of pairs grows, not as the chains grow, and the pairs run in parallel without communication. Their meeting times also bound the distance of the chains from stationarity.
telescopic is written in Python on NumPy and SciPy. It is in development; version 0.1 is a first draft. The documentation is at https://joshspeagle.com/telescopic/.
Installation
Install telescopic from a clone of the repository:
pip install . # or pip install ".[all]" for every extra
It needs Python 3.11 or newer, NumPy 1.26 or newer, SciPy 1.12 or newer and
threadpoolctl 3.1 or newer. The extras are plot (matplotlib), progress (tqdm),
parallel (cloudpickle, which sends functions defined in notebooks to worker
processes), pandas (summaries as data frames), arviz (chains exported to
ArviZ 1.0 or newer, which needs Python 3.12 and NumPy 2) and all.
Example
The script below fits a straight line to data with Gaussian errors:
import numpy as np
from scipy import optimize
import telescopic
rng = np.random.default_rng(0)
x = np.sort(10 * rng.random(50))
yerr = 0.1 + 0.5 * rng.random(50)
y = -0.9 * x + 4.3 + yerr * rng.normal(size=50)
def log_prob(theta, x, y, yerr):
slope, intercept = theta
return -0.5 * np.sum(((y - slope * x - intercept) / yerr) ** 2)
# Start the chains from a Gaussian ten times wider than the best fit's errors.
fit = optimize.minimize(lambda theta: -log_prob(theta, x, y, yerr), [0.0, 0.0])
init = telescopic.initial.Normal(mean=fit.x, cov=100 * fit.hess_inv)
result = telescopic.sample(log_prob, init, args=(x, y, yerr), names=["slope", "intercept"],
rng=42)
print(result.summary()) # unbiased means, standard errors, quantiles
result.estimate(lambda t: t[:, 0] * t[:, 1]) # any function, after the run
result.plot_tv_bound() # with the plot extra: distance from stationarity
sample tunes a random-walk kernel on pilot chains, chooses the burn-in, the lag and the
length of each run from the meeting times of pilot pairs, runs 100 replicates, and warns
when the run shows signs that its error bars are unreliable. The chains should start
wider than the posterior, but not by orders of magnitude
(Initial distributions).
The Quickstart explains this example, and the
tutorials work through others.
What it guarantees
Each replicate's estimate is unbiased for any burn-in, lag and run length, and every initial distribution from which the chain converges, provided the coupling keeps each chain's law, the chains stay together once they meet, and the meeting time has enough moments. With finite variance, the error bars are valid as the number of replicates grows. Coupling does not make the chains mix faster, and a run whose initial distribution or tuned kernel misses a mode can be confidently wrong. The theory page states the conditions and the limits.
Citing
If you use telescopic, please cite the software (CITATION.cff) and the
methods it implements, which Citing lists.
License
MIT.
Metadata
Release files for telescopic 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| telescopic-0.1.0.tar.gz | 308.5 kB | With provenance | Details for telescopic-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| telescopic-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for telescopic-0.1.0-py3-none-any.whl |
Total release size: 467.1 kB
Release files / telescopic-0.1.0.tar.gz
| Download URL | telescopic-0.1.0.tar.gz |
|---|---|
| Size | 308.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c17507f612412079fa0170f949f3642df4b11135567b824c0647860e921fad8c
|
|
BLAKE2b-256 checksum How to use checksums |
fa75d98b622bfc8ea79cac2c5628d1286128f0a2fc35fca162b525dbf8d32103
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / telescopic-0.1.0-py3-none-any.whl
| Download URL | telescopic-0.1.0-py3-none-any.whl |
|---|---|
| Size | 158.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdd57bece53fa7fc4fdf85c5ace4c836338d72b1d58019008403948040e3bb19
|
|
BLAKE2b-256 checksum How to use checksums |
8bc15d4f87682490e4ac1e28e99e2c2b1328aed775e2f1342437498db5c43fad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for telescopic 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for telescopic-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.