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

[1]“Covariance-Adaptive Slice Sampling”, 2010, M Thompson and RM Neal, Technical Report No. 1002, Department of Statistics, University of Toronto
[2]“Slice sampling”, 2003, Neal, R.M., The annals of statistics, 31(3), pp.705-767. https://doi.org/10.1214/aos/1056562461
ask()[source]

See SingleChainMCMC.ask().

current_slice_height()[source]

Returns the height of the current slice.

in_initial_phase()

For methods that need an initial phase (see needs_initial_phase()), this method returns True if the method is currently configured to be in its initial phase. For other methods a NotImplementedError is returned.

n_hyper_parameters()[source]

See TunableMethod.n_hyper_parameters().

name()[source]

See pints.MCMCSampler.name().

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.

needs_sensitivities()[source]

See pints.MCMCSampler.needs_sensitivities().

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]. See TunableMethod.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 a NotImplementedError is returned.

set_sigma_c(sigma_c)[source]

Sets standard deviation of initial crumb distribution.

sigma_c()[source]

Returns standard deviation of initial crumb distribution.

tell(reply)[source]

See pints.SingleChainMCMC.tell().