Slice Sampler

class sampyl.Slice(logp, start, compwise=False, width=1.0, step_out=True, doubling_step=True, max_steps_out=10, verbose=False, **kwargs)

Slice sampler (Neal, 2003) for creating a Markov chain that leaves the the distribution defined by logp invariant

For technical details, see Neal’s paper:
http://projecteuclid.org/euclid.aos/1056562461

Andrew Miller (acm@seas.harvard.edu) 7-13-15

Adapted from code written by Ryan Adams (rpa@seas.harvard.edu)

Parameters:
  • logpfunction. \(\log{P(X)}\) function for sampling distribution.
  • startscalar or 1D array-like. Starting state for sampler.
  • compwise – (optional) boolean. Component-wise univariate slice sample (or random direction)
  • width – (optional) int, float. (Initial) width of the slice
  • step_out – (optional) boolean. Perform step-out procedure
  • doubling_step – (optional) boolean. If stepping out, double slice width?
  • max_steps_out – (optional) int. Max number of steps out to perform
  • verbose – (optional) boolean. Print steps out
direction_slice(direction, init_x)

one dimensional directional slice sample along direction specified Implements the stepping out procedure from Neal

sample(num, burn=0, thin=1, n_chains=1, progress_bar=True)

Sample from \(P(X)\)

Parameters:
  • numint. Number of samples to draw from \(P(X)\).
  • burn – (optional) int. Number of samples to discard from the beginning of the chain.
  • thin – (optional) float. Thin the samples by this factor.
  • n_chains – (optional) int. Number of chains to return. Each chain is given its own process and the OS decides how to distribute the processes.
  • progress_bar – (optional) boolean. Show the progress bar, default = True.
Returns:

Record array with fields taken from arguments of logp function.

step()

Perform a slice sample step