Thesis docs
Loading...
Searching...
No Matches
Sampler Class Referenceabstract

Abstract base class for MCMC sampler implementations. More...

#include <Sampler.hpp>

Inheritance diagram for Sampler:
Neal3 SplitMerge SplitMerge_SAMS

Public Member Functions

 Sampler (Data &d, Params &p, Likelihood &l, Process &pr)
 Constructor initializing sampler with required components.
 
virtual void step ()=0
 Pure virtual method to perform one MCMC sampling step.
 
virtual ~Sampler ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Protected Attributes

Datadata
 Reference to the data object containing observations and current allocations.
 
Paramsparams
 Reference to the parameters object containing model hyperparameters and MCMC settings.
 
Likelihoodlikelihood
 Reference to the likelihood computation object for evaluating cluster assignments.
 
Processprocess
 Reference to the stochastic process object (DP, NGGP, DPW, NGGPW)
 
std::random_device rd
 Random device for generating random numbers across sampling algorithms.
 

Detailed Description

Abstract base class for MCMC sampler implementations.

This class provides the foundation for implementing different MCMC sampling algorithms for Bayesian nonparametric models including Dirichlet Process (DP), Normalized Generalized Gamma Process (NGGP), and their weighted variants (DPW, NGGPW). It holds references to all necessary components and provides a unified interface for different sampling strategies.

The class supports various MCMC algorithms through derived implementations:

  • Gibbs Samplers: Standard collapsed Gibbs sampling (Neal's Algorithm 3)
  • Split-Merge Samplers: Advanced algorithms for better mixing (SAMS variants)
  • Hybrid Approaches: Combinations of different sampling strategies

Each sampler operates on the same core components but implements different strategies for exploring the posterior distribution of cluster assignments. The composition pattern allows flexible combinations of different data types, likelihood models, process priors, and parameter configurations.

See also
Data, Params, Likelihood, Process
Neal3, SplitMerge, SplitMerge_SAMS

Constructor & Destructor Documentation

◆ Sampler()

Sampler::Sampler ( Data & d,
Params & p,
Likelihood & l,
Process & pr )
inline

Constructor initializing sampler with required components.

Parameters
dReference to Data object containing observations and current cluster assignments
pReference to Params object containing hyperparameters and simulation settings
lReference to Likelihood object for evaluating assignment probabilities
prReference to Process object (DP, NGGP, DPW, or NGGPW) defining the prior

The constructor establishes references to all components needed for MCMC sampling. The specific behavior depends on the concrete implementations of each component:

  • Different Process types (DP vs NGGP) yield different clustering behaviors
  • Different Likelihood models handle various data types and distributions
  • Parameter settings control burn-in, iterations, and hyperparameter values

◆ ~Sampler()

virtual Sampler::~Sampler ( )
virtualdefault

Virtual destructor for proper cleanup of derived classes.

Member Function Documentation

◆ step()

virtual void Sampler::step ( )
pure virtual

Pure virtual method to perform one MCMC sampling step.

This method must be implemented by derived classes to define their specific sampling algorithm. Each call should update the current state of the Markov chain by sampling from the appropriate conditional distributions.

Different sampler implementations use different strategies:

  • Gibbs samplers (e.g., Neal3): Sequential sampling of individual assignments
  • Split-Merge samplers: Joint updates of multiple assignments via split/merge moves
  • Hybrid samplers: Combinations of multiple update mechanisms

The method should update cluster assignments in the Data object and may also update auxiliary variables or hyperparameters as needed by the specific algorithm.

Note
This is a pure virtual function that must be overridden by concrete sampler implementations
See also
Neal3::step(), SplitMerge::step(), SplitMerge_SAMS::step()

Implemented in Neal3, SplitMerge, and SplitMerge_SAMS.

Member Data Documentation

◆ data

Data& Sampler::data
protected

Reference to the data object containing observations and current allocations.

◆ likelihood

Likelihood& Sampler::likelihood
protected

Reference to the likelihood computation object for evaluating cluster assignments.

◆ params

Params& Sampler::params
protected

Reference to the parameters object containing model hyperparameters and MCMC settings.

◆ process

Process& Sampler::process
protected

Reference to the stochastic process object (DP, NGGP, DPW, NGGPW)

◆ rd

std::random_device Sampler::rd
protected

Random device for generating random numbers across sampling algorithms.


The documentation for this class was generated from the following file: