Discrete Gibbs Sampler (DGS)

Implementation of a sampler for the simulation of discrete or discretized model parameters with finite support. Draws are simulated directly from a probability mass function that can be specified up to a constant of proportionality. Note that versions of this sampler evaluate the probability function over all points in the parameter space; and, as a result, may be very computationally intensive for large spaces.

Model-Based Constructor


Construct a Sampler object for which DGS sampling is to be applied separately to each of the supplied parameters. Parameters are assumed to have discrete univariate distributions with finite supports.


  • params : stochastic node(s) to be updated with the sampler.


Returns a Sampler{DSTune{Function}} type object.


See the Eyes, Pollution, and other Examples.

Stand-Alone Functions


Draw one sample directly from a target probability mass function. Parameters are assumed to have discrete and finite support.


  • v : current state of parameters to be simulated.


Returns v updated with simulated values and associated tuning parameters.

Discrete Variate Types


typealias DGSVariate SamplerVariate{DSTune{Function}}
typealias DiscreteVariate SamplerVariate{DSTune{Vector{Float64}}}


  • value::Vector{Float64} : simulated values.
  • tune::DSTune{F<:DSForm} : tuning parameters for the sampling algorithm.


DGSVariate(x::AbstractVector{T<:Real}, support::Matrix{U<:Real}, mass::Function)
DiscreteVariate(x::AbstractVector{T<:Real}, support::Matrix{U<:Real}, mass::Vector{Float64})

Construct an object that stores simulated values and tuning parameters for discrete sampling.


  • x : initial values.
  • support : matrix whose columns contain the vector coordinates in the parameter space from which to simulate values.
  • mass : function that takes a single DenseVector argument of parameter values at which to compute the density (up to a normalizing constant), or a vector of sampling probabilities for the parameter space.


Returns a DGSVariate or DiscreteVariate type object with fields set to the supplied x and tuning parameter values.

DSTune Type


typealias DSForm Union{Function, Vector{Float64}}
type DSTune{F<:DSForm} <: SamplerTune


  • mass::Nullable{F} : density mass function or vector supplied to the constructor, or null if not supplied.
  • support::Matrix{Real} : matrix whose columns contain the vector coordinates in the parameter space from which to simulate values.