telescopic.couplings¶
Couplings of pairs of distributions: the primitives that coupled kernels build on.
Classes
The coupled proposals of |
|
A coupling of the proposals of two chains under one proposal. |
|
The rejection maximal coupling of two random-walk proposals. |
|
The reflection-maximal coupling of two Gaussian proposals with a shared covariance. |
|
The coupling of two independence proposals that gives both chains one proposal. |
- telescopic.couplings.discrete_maximal(log_p, log_q, draws)¶
Maximal coupling of two distributions on \(\{0, \dots, K-1\}\), row by row.
With probability \(\alpha = \sum_k \min(p_k, q_k)\) both indices are drawn from \(\min(p, q)/\alpha\); otherwise they are drawn independently from the normalized residuals \(p - \min(p, q)\) and \(q - \min(p, q)\), whose supports are disjoint (Jacob, O’Leary & Atchadé 2020, section 5.4). So \(P(i = j) = \alpha = 1 - \mathrm{TV}(p, q)\).
- telescopic.couplings.maximal(p, q, draws, eta=1.0)¶
Rejection maximal coupling of the distributions
p[i]andq[i]of each row.Draw \(X \sim p\); the pair is identical with probability \(\min(\eta, q(X)/p(X))\). Otherwise draw \(Y \sim q\) until \(u > \eta\,p(Y)/q(Y)\) (Thorisson’s algorithm, Jacob, O’Leary & Atchadé 2020 Algorithm 2; with \(\eta < 1\), the bounded-variance version of Gerber & Lee 2020, Atchadé & Jacob 2024 Algorithm 2). The meeting probability is \(\int\min(\eta p, q)\) over the draws whose log-densities are finite, maximal at \(\eta = 1\); the number of draws from
pandqhas mean 2 and variance at most \(2\eta/(1-\eta)\).Where either log-density of a draw is infinite, the pair is not identical and the loop accepts the draw. Such a draw, as one that underflowed to the edge of its support, stands for the mass of an interval whose ratio of densities is unknown, and each chain keeps its sampler’s law. Such draws can be frequent: a third of Beta(0.01, 0.01)’s are 1.0, its mass within \(2^{-53}\) of 1, where the pair is not identical even for \(p = q\), though its draws can be equal.
- Parameters:
- p, q
listof distributions, length n Objects with
rvs(random_state=...)and a normalizedlogpdf(orlogpmf), such as frozen SciPy distributions. All draws have the same shape. Values oflogpdffor the coordinates of a draw are summed, as the joint log-density of independent coordinates; NaN raisesValueError.- draws
Draws Random numbers for the
nrows; each row draws from its own generator.- eta
float Cap on the meeting probability, in (0, 1].
- p, q
- Returns:
- telescopic.couplings.reflection_maximal(mu_x, mu_y, chol, inverse, draws, *, blas=False)¶
Reflection-maximal coupling of \(\mathcal N(\mu_x, CC^\top)\) and \(\mathcal N(\mu_y, CC^\top)\).
With \(\delta = C^{-1}(\mu_x - \mu_y)\), \(z \sim \mathcal N(0, I)\) and \(x = \mu_x + Cz\), the pair is identical when \(\log u < -z\cdot\delta - \lVert\delta\rVert^2/2\); otherwise \(y = \mu_y + C(z - 2(e\cdot z)e)\) with \(e = \delta/\lVert\delta\rVert\), or \(e = 0\) where \(\lVert\delta\rVert^2\) is 0 or not finite (Jacob, O’Leary & Atchadé 2020, section 4.1). The coupling is maximal: \(P(x = y) = 2\Phi(-\lVert\delta\rVert/2)\).
- Parameters:
- mu_x, mu_y
ndarray, shape (n, d) Means of the two Gaussians of each row.
- chol
ndarray, shape (d, d) Lower-triangular factor \(C\) of the shared covariance.
- inverse
ndarray, shape (d, d) \(C^{-1}\), which whitens the difference of the means.
- draws
Draws Random numbers for the
nrows; each row usesdnormals and 1 uniform.- blasbool
Whether to compute the products with \(C\) and \(C^{-1}\) by BLAS (
vectors @ matrix.T), which gives a row bits that can depend on the other rows and on the number of BLAS threads; kernels set it for vectorized targets. Otherwise a row’s arithmetic does not depend on the other rows.
- mu_x, mu_y
- Returns: