RandomWalk

class telescopic.kernels.RandomWalk(cov=None, *, scale=None, coupling='reflection')

Random-walk Metropolis-Hastings with a Gaussian proposal.

The proposal is \(x' = x + \lambda C z\) with \(CC^\top = \Sigma\) (cov), \(\lambda\) (scale) and \(z \sim \mathcal N(0, I)\); it is accepted when \(\log u < \log\pi(x') - \log\pi(x)\). It is a MetropolisHastings with a RandomWalkProposal.

Parameters:
covarray_like, shape (d, d), optional

Shape of the proposal, usually an estimate of the target covariance. None leaves the kernel untuned: tune() sets it to the covariance of adaptive Metropolis pilot chains.

scalefloat, optional

Scale \(\lambda\); defaults to \(2.38/\sqrt d\), the optimal scale for a Gaussian target whose covariance is cov (Roberts, Gelman & Gilks 1997).

coupling{“reflection”, “maximal”}, Reflection or Maximal

"reflection", or Reflection, couples the proposals by the reflection-maximal coupling and uses one uniform for both acceptances (Jacob, O’Leary & Atchadé 2020; O’Leary 2021). "maximal", or Maximal, uses the rejection maximal coupling with independent residuals, whose meeting times grow exponentially with the dimension; it is for comparison only. The attribute coupling returns what was given, and cannot be reassigned.

Notes

A step uses d normals and 1 uniform; a coupled step with the reflection coupling uses d normals and 2 uniforms and at most two log-density evaluations per pair, one when the proposals coincide. With the maximal coupling, a coupled step draws proposals of d normals and 1 uniform each from each pair’s own generator (generator()), two per pair on average for a pair apart and one for a pair that has met, then 1 uniform for both acceptances.

Examples

A kernel left without cov is tuned by the sampler, which keeps the tuned copy in the result and leaves the kernel passed to it as it was:

>>> from telescopic import examples, kernels, sample
>>> example = examples.gaussian(2)
>>> kernel = kernels.RandomWalk()
>>> result = sample(
...     example.log_prob, example.initial, kernel=kernel,
...     n_replicates=50, vectorize=True, rng=0,
... )
>>> kernel.is_tuned, result.kernel.is_tuned
(False, True)
property coupling

The coupling as it was given: a name or a coupling object.

Returns:
str, Reflection or Maximal