telescopic¶
Unbiased Markov chain Monte Carlo from pairs of coupled chains.
telescopic runs pairs of Markov chains under a coupling that makes the two chains meet, and turns each pair into an unbiased estimate of expectations under the target. Averages over independent pairs have error bars that are valid as the number of pairs grows, not as the chains grow. Theory states the conditions and the limits.
One coupled pair run by telescopic on a standard normal target with random-walk Metropolis, drawn against time: Xt in magenta and Yt-1 in teal, as the estimator pairs them with a lag of 1. The lines join at the meeting time, and one chain continues.¶
I use emcee and want error bars I can trust
The same line fit with emcee and with telescopic, side by side.
-
One run taken apart: pairs that meet, and the correction that removes the bias.
-
Find the error or warning you see, its cause and what to change.
This example estimates the mean of a correlated Gaussian, (0, 0), and the mean of the product of its coordinates, 0.9.
import numpy as np
import telescopic
cov = np.array([[1.0, 0.9], [0.9, 1.0]])
precision = np.linalg.inv(cov)
def log_prob(theta):
return -0.5 * theta @ precision @ theta
init = telescopic.initial.Normal(mean=[0.0, 0.0], cov=4 * cov)
result = telescopic.sample(log_prob, init, rng=1)
print(result.estimate(lambda t: t))
print(result.estimate(lambda t: t[:, 0] * t[:, 1]))
Estimate([-0.00256289 ± 0.018, -0.0101729 ± 0.02], R=100)
Estimate(0.919411 ± 0.024, R=100)