bss.samplers package

Submodules

bss.samplers.elliptical module

class bss.samplers.elliptical.EllipticalSliceSampler(normal_dist, log_like_fn)

Elliptical Slice Sampling algorithm as outlined in [MAM10].

Parameters:

normal_dist : object

Object representing the normal distribution that current_state is sampled from. This object needs to be able to supply a d-dimensional variate through an rvs() method.

log_like_fn : callable

Log Likelihood function that takes in a single argument, a d-dimensional vector representing a state, and returns a scalar log-likelihood value

Methods

chain(x0=None, iters=100000, burn_in=50000)

Generate a fixed number of samples, for a given burn_in and no. of iterations

Parameters:

x0 : ndarray, optional

The starting point of the sampling process, a dx1 vector

iters: int, optional

The no. of iterations of sampling to run, including the burn-in, if any.

burn_in: int, optional

The no. of samples to discard as burn-in samples.

Returns:

list

A list of iters-burn_in samples, each a dx1 numpy vector

one(x0=None)

Generate a single sample, given the starting point of sampling.

Parameters:

x0 : ndarray, optional

The starting point of the sampling process, a dx1 vector

Returns:

ndarray

A single sample, a dx1 vector

start(x0=None)

Start the sampling process at a given point defined by x0

Parameters:

x0 : ndarray, optional

The starting point of the sampling process, a dx1 vector

Returns:

iterable

A (never-ending) iterable of dx1 samples from slice-sampling

bss.samplers.slice module

class bss.samplers.slice.SliceSampler(logprob, w=1.0, expand=True, max_steps_out=1000, compwise=True, doubling_step=True)

Exponential-Expansion slice sampling as per [Nea03]

Parameters:

logprob : callable

A function taking a single sample (a dx1 ndarray), and returning the log-probability of that sample

w : float, optional

Estimate of the typical size of a slice

expand : bool, optional

Whether to expand the slice size, either by linear increments or a doubling process

max_steps_out : int, optional

The max. no. of expansion steps to take, either in a single direction (when stepping out in fixed-width increments), or the total max steps in both directions (when stepping out using doubling steps).

compwise : bool, optional

Whether we’re exploring the space component-wise by taking a step in each dimension (default behavior), or if we take a single step in a random direction in each iteration of the sampling.

doubling_step : bool, optional

Whether to use the doubling procedure described to expand the slice size; Useful to expand intervals faster than stepping out in fixed-width increments.

Methods

chain(x0=None, iters=100000, burn_in=50000)

Generate a fixed number of samples, for a given burn_in and no. of iterations

Parameters:

x0 : ndarray, optional

The starting point of the sampling process, a dx1 vector

iters: int, optional

The no. of iterations of sampling to run, including the burn-in, if any.

burn_in: int, optional

The no. of samples to discard as burn-in samples.

Returns:

list

A list of iters-burn_in samples, each a dx1 numpy vector

one(x0=None)

Generate a single sample, given the starting point of sampling.

Parameters:

x0 : ndarray, optional

The starting point of the sampling process, a dx1 vector

Returns:

ndarray

A single sample, a dx1 vector

start(x0=None)

Start the sampling process at a given point defined by x0

Parameters:

x0 : ndarray, optional

The starting point of the sampling process, a dx1 vector

Returns:

iterable

A (never-ending) iterable of dx1 samples from slice-sampling

Module contents