THRML

Conditional samplers

Conditional samplers draw a block's new state given its neighbors. They are the per-block kernels that block Gibbs strings together.

AbstractConditionalSamplerclass
AbstractConditionalSampler()

Base class for all conditional samplers.

A conditional sampler is used to update the state of a block of nodes during each iteration of a sampling algorithm. It takes in the states of all the neighbors and produces a sample for the current block of nodes. This can often be done exactly, but need not be. One could embed MCMC methods within this sampler (to do Metropolis within Gibbs, for example).

AbstractParametricConditionalSamplerclass
AbstractParametricConditionalSampler()

A conditional sampler that leverages a parameterized distribution.

When sample is called, this sampler will first compute a set of parameters, and then use those parameters to draw a sample from some distribution. This workflow is frequently useful in practical cases; for example, to sample from a Gaussian, we can first compute a mean vector and covariance matrix using any procedure, and then draw a sample from the corresponding Gaussian distribution by appropriately transforming a vector of standard normal random variables.

BernoulliConditionalclass
BernoulliConditional()

Sample from a bernoulli distribution.

This sampler is designed to sample from a spin-valued bernoulli distribution:

$$\mathbb{P}(S=s) \propto e^{\gamma s}$$

where $S$ is a spin-valued random variable, $s \in \{-1, 1\}$. The parameter $\gamma$ must be computed by compute_parameters.

SoftmaxConditionalclass
SoftmaxConditional()

Sample from a softmax distribution.

This sampler samples from the standard softmax distribution:

$$\mathbb{P}(X=k) \propto e^{\theta_k}$$

where $X$ is a categorical random variable and $\theta$ is a vector that parameterizes the relative probabilities of each of the categories.