Slice Sampling - Rank Shrinking MCMC¶
- class pints.SliceRankShrinkingMCMC(x0, sigma0=None)[source]¶
Implements Covariance-Adaptive slice sampling by “rank shrinking”, as introduced in [1] with pseudocode given in Fig. 5.
This is an adaptive multivariate method which uses additional points, called “crumbs”, and rejected proposals to guide the selection of samples.
It generates samples by sampling uniformly from the volume underneath the posterior (\(f\)). It does so by introducing an auxiliary variable (\(y\)) that guide the path of a Markov chain.
Sampling follows:
1. Calculate the pdf (\(f(x_0)\)) of the current sample \((x_0)\). 2. Draw a real value (\(y\)) uniformly from \((0, f(x0))\), defining a horizontal “slice”: \(S = {x: y < f(x)}\). Note that \(x_0\) is always within \(S\). 3. Draw the first crumb (\(c_1\)) from a Gaussian distribution with mean \(x_0\) and precision matrix \(W_1\). 4. Draw a new point (\(x_1\)) from a Gaussian distribution with mean \(c_1\) and precision matrix \(W_2\).
New crumbs are drawn until a new proposal is accepted. In particular, after sampling \(k\) crumbs from Gaussian distributions with mean \(x0\) and precision matrices \((W_1, ..., W_k)\), the distribution for the kth proposal sample is:
\[x_k \sim Normal(\bar{c}_k, \Lambda^{-1}_k)\]where:
\(\Lambda_k = W_1 + ... + W_k\) \(\bar{c}_k = \Lambda^{-1}_k * (W_1 * c_1 + ... + W_k * c_k)\)
This method aims to conveniently modify the (k+1)th proposal distribution to increase the likelihood of sampling an acceptable point. It does so by calculating the gradient (\(g(f(x))\)) of the unnormalised posterior (\(f(x)\)) at the last rejected point (\(x_k\)). It then sets the conditional variance of the (k + 1)th proposal distribution in the direction of the gradient \(g(f(x_k))\) to 0. This is reasonable in that the gradient at a proposal probably points in a direction where the variance is small, so it is more efficient to move in a different direction.
To avoid floating-point underflow, we implement the suggestion advanced in [2] pp.712. We use the log pdf of the un-normalised posterior (\(\text{log} f(x)\)) instead of \(f(x)\). In doing so, we use an auxiliary variable \(z = log(y) - \epsilon\), where \(\epsilon \sim \text{exp}(1)\) and define the slice as \(S = {x : z < log f(x)}\).
Extends
SingleChainMCMC
.References
- in_initial_phase()¶
For methods that need an initial phase (see
needs_initial_phase()
), this method returnsTrue
if the method is currently configured to be in its initial phase. For other methods aNotImplementedError
is returned.
- needs_initial_phase()¶
Returns
True
if this method needs an initial phase, for example an adaptation-free period for adaptive covariance methods, or a warm-up phase for DREAM.
- replace(current, current_log_pdf, proposed=None)¶
Replaces the internal current position, current LogPDF, and proposed point (if any) by the user-specified values.
This method can only be used once the initial position and LogPDF have been set (so after at least 1 round of ask-and-tell).
This is an optional method, and some samplers may not support it.
- set_hyper_parameters(x)[source]¶
The hyper-parameter vector is
[sigma_c]
. SeeTunableMethod.set_hyper_parameters()
.
- set_initial_phase(in_initial_phase)¶
For methods that need an initial phase (see
needs_initial_phase()
), this method toggles the initial phase algorithm. For other methods aNotImplementedError
is returned.