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 aMetropolisHastingswith aRandomWalkProposal.- Parameters:
- covarray_like, shape (d, d), optional
Shape of the proposal, usually an estimate of the target covariance.
Noneleaves the kernel untuned:tune()sets it to the covariance of adaptive Metropolis pilot chains.- scale
float, 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", orReflection, couples the proposals by the reflection-maximal coupling and uses one uniform for both acceptances (Jacob, O’Leary & Atchadé 2020; O’Leary 2021)."maximal", orMaximal, uses the rejection maximal coupling with independent residuals, whose meeting times grow exponentially with the dimension; it is for comparison only. The attributecouplingreturns what was given, and cannot be reassigned.
Notes
A step uses
dnormals and 1 uniform; a coupled step with the reflection coupling usesdnormals 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 ofdnormals 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
covis 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)