MALA¶
- class telescopic.kernels.MALA(step_size=None, *, cov=None)¶
The Metropolis-adjusted Langevin algorithm.
The proposal is \(x' = x + \tfrac{\epsilon^2}{2}\Sigma\nabla\log\pi(x) + \epsilon Cz\), with \(CC^\top = \Sigma\) (
cov) and \(z \sim \mathcal N(0, I)\), a draw from \(q(\cdot \mid x)\). It is accepted when \(\log u < \log\pi(x') - \log\pi(x) + \log q(x \mid x') - \log q(x' \mid x)\); a proposal with a log-density of-infor a non-finite position is rejected. Coupled chains draw their proposals from the reflection-maximal coupling of their proposal distributions, which share the covariance \(\epsilon^2\Sigma\), and share the uniform (Jacob, O’Leary & Atchadé 2020, section 4.4): aMetropolisHastingswith aLangevinProposalandReflection.- Parameters:
- step_size
float, optional \(\epsilon\).
Noneleaves it totune(): dual averaging toward an acceptance rate of 0.574 from \(\epsilon_0 = 1.65\,d^{-1/6}\) (Roberts & Rosenthal 1998).- covarray_like, shape (d, d), optional
\(\Sigma\), usually an estimate of the target covariance.
Noneleaves it totune(), which takes the covariance of adaptive Metropolis pilot chains.
- step_size
Notes
A step uses
dnormals and 1 uniform, and a coupled stepdnormals and 2 uniforms. Each evaluates the log-density once per chain, once per pair when the proposals coincide, and the gradient where the log-density is finite.Both compute in whitened coordinates. With \(B = \epsilon C\) and the whitened drift \(h = B^\top\nabla\log\pi(x)\), the proposal is \(x' = x + B(h/2 + z)\) and the log ratio of the proposal densities is \((\lVert z\rVert^2 - \lVert z + (h + h')/2\rVert^2)/2\), so a step costs 3 products of a row with a \(d \times d\) factor and a coupled step 7.
Examples
MALA needs the gradient, as
gradorlog_prob_and_grad, which it evaluates with every finite log-density, so on a Gaussian the two counts agree:>>> from telescopic import examples, kernels, sample >>> example = examples.gaussian(2) >>> result = sample( ... example.log_prob, example.initial, grad=example.grad, ... kernel=kernels.MALA(), n_replicates=50, vectorize=True, rng=0, ... ) >>> result.n_grad == result.n_log_prob True