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

Abstract base class for Bayesian nonparametric processes. More...

#include <Process.hpp>

Inheritance diagram for Process:
DP DPW NGGP NGGPW

Public Member Functions

 Process (Data &d, Params &p)
 Constructor initializing process with data and parameters.
 
virtual double gibbs_prior_existing_cluster (int cls_idx, int obs_idx) const =0
 Compute prior probability for assigning observation to existing cluster.
 
virtual Eigen::VectorXd gibbs_prior_existing_clusters (int obs_idx) const =0
 Compute prior probabilities for assigning observation to all existing clusters.
 
virtual double gibbs_prior_new_cluster () const =0
 Compute prior probability for creating a new cluster.
 
virtual double prior_ratio_split (int ci, int cj) const =0
 Compute prior ratio for split move in split-merge algorithm.
 
virtual double prior_ratio_merge (int size_old_ci, int size_old_cj) const =0
 Compute prior ratio for merge move in split-merge algorithm.
 
virtual double prior_ratio_shuffle (int size_old_ci, int size_old_cj, int ci, int cj) const =0
 Compute prior ratio for shuffle move in split-merge algorithm.
 
void set_old_allocations (const Eigen::VectorXi &new_allocations)
 Store current allocations for potential rollback.
 
void set_idx_i (int i)
 Set index of first observation in split-merge pair.
 
void set_idx_j (int j)
 Set index of second observation in split-merge pair.
 
virtual void update_params ()=0
 Update process parameters during MCMC sampling.
 
virtual ~Process ()
 Virtual destructor for proper cleanup of derived classes.
 

Protected Attributes

Datadata
 Reference to the data object containing observations and allocations.
 
Paramsparams
 Reference to the parameters object containing process hyperparameters.
 
Eigen::VectorXi old_allocations
 Storage for previous allocations to enable rollback in case of rejection.
 
int idx_i
 Index of first observation involved in split-merge move.
 
int idx_j
 Index of second observation involved in split-merge move.
 
const double log_a = log(params.a)
 Precomputed logarithm of total mass parameter for efficiency.
 

Detailed Description

Abstract base class for Bayesian nonparametric processes.

This class provides the foundation for implementing different types of Bayesian nonparametric processes including Dirichlet Process (DP), Normalized Generalized Gamma Process (NGGP), and their weighted variants (DPW, NGGPW). It defines the interface for prior computations needed in both Gibbs sampling and split-merge MCMC algorithms.

The class handles:

  • Prior probability computations for existing and new clusters
  • Prior ratio calculations for split-merge moves
  • Parameter updates during MCMC sampling
  • State management for split-merge algorithms

Derived classes must implement the pure virtual methods to define their specific process characteristics (DP, NGGP, NGGPW, DPW).

See also
DP, NGGP, NGGPW, DPW

Constructor & Destructor Documentation

◆ Process()

Process::Process ( Data & d,
Params & p )
inline

Constructor initializing process with data and parameters.

Parameters
dReference to Data object containing observations and current allocations
pReference to Params object containing process hyperparameters

Initializes the process and stores a copy of current allocations for potential rollback operations during split-merge moves.

◆ ~Process()

virtual Process::~Process ( )
inlinevirtual

Virtual destructor for proper cleanup of derived classes.

Member Function Documentation

◆ gibbs_prior_existing_cluster()

virtual double Process::gibbs_prior_existing_cluster ( int cls_idx,
int obs_idx ) const
pure virtual

Compute prior probability for assigning observation to existing cluster.

Parameters
cls_idxIndex of the existing cluster
obs_idxIndex of the observation to be assigned
Returns
Log prior probability of assignment to existing cluster

This method computes the prior component of the probability for assigning an observation to an existing cluster in Gibbs sampling. The exact computation depends on the specific process (DP, NGGP, etc.).

Implemented in DP, DPW, NGGP, and NGGPW.

◆ gibbs_prior_existing_clusters()

virtual Eigen::VectorXd Process::gibbs_prior_existing_clusters ( int obs_idx) const
pure virtual

Compute prior probabilities for assigning observation to all existing clusters.

Parameters
obs_idxIndex of the observation to be assigned
Returns
Vector of log prior probabilities for all existing clusters

This method computes the prior components of the probabilities for assigning an observation to each existing cluster in Gibbs sampling. The exact computation depends on the specific process (DP, NGGP, etc.). The returned vector has a length equal to the current number of clusters.

Implemented in DP, DPW, NGGP, and NGGPW.

◆ gibbs_prior_new_cluster()

virtual double Process::gibbs_prior_new_cluster ( ) const
pure virtual

Compute prior probability for creating a new cluster.

Returns
Log prior probability of creating a new cluster

This method computes the prior probability of assigning an observation to a new cluster in Gibbs sampling. The computation is process-specific.

Implemented in DP, DPW, NGGP, and NGGPW.

◆ prior_ratio_merge()

virtual double Process::prior_ratio_merge ( int size_old_ci,
int size_old_cj ) const
pure virtual

Compute prior ratio for merge move in split-merge algorithm.

Parameters
size_old_ciSize of first cluster before merge
size_old_cjSize of second cluster before merge
Returns
Log prior ratio for the merge move

Computes the ratio of prior probabilities when merging two clusters into one cluster. Used in the acceptance probability of merge moves.

Implemented in DP, DPW, NGGP, and NGGPW.

◆ prior_ratio_shuffle()

virtual double Process::prior_ratio_shuffle ( int size_old_ci,
int size_old_cj,
int ci,
int cj ) const
pure virtual

Compute prior ratio for shuffle move in split-merge algorithm.

Parameters
size_old_ciSize of first cluster before shuffle
size_old_cjSize of second cluster before shuffle
ciIndex of first cluster after shuffle
cjIndex of second cluster after shuffle
Returns
Log prior ratio for the shuffle move

Computes the ratio of prior probabilities when redistributing observations between two existing clusters. Used in restricted Gibbs sampling.

Implemented in DP, DPW, NGGP, and NGGPW.

◆ prior_ratio_split()

virtual double Process::prior_ratio_split ( int ci,
int cj ) const
pure virtual

Compute prior ratio for split move in split-merge algorithm.

Parameters
ciIndex of first resulting cluster after split
cjIndex of second resulting cluster after split
Returns
Log prior ratio for the split move

Computes the ratio of prior probabilities when splitting a cluster into two clusters. Used in the acceptance probability of split moves.

Implemented in DP, DPW, NGGP, and NGGPW.

◆ set_idx_i()

void Process::set_idx_i ( int i)
inline

Set index of first observation in split-merge pair.

Parameters
iIndex of first observation

◆ set_idx_j()

void Process::set_idx_j ( int j)
inline

Set index of second observation in split-merge pair.

Parameters
jIndex of second observation

◆ set_old_allocations()

void Process::set_old_allocations ( const Eigen::VectorXi & new_allocations)
inline

Store current allocations for potential rollback.

Parameters
new_allocationsCurrent allocation vector to store

Saves the current state of cluster allocations before attempting a split-merge move, enabling rollback if the move is rejected.

◆ update_params()

virtual void Process::update_params ( )
pure virtual

Update process parameters during MCMC sampling.

This method allows derived classes to update their specific parameters during the MCMC chain. For example, some processes may need to sample hyperparameters or update auxiliary variables. Implementation is process-specific.

Implemented in DP, DPW, NGGP, and NGGPW.

Member Data Documentation

◆ data

Data& Process::data
protected

Reference to the data object containing observations and allocations.

◆ idx_i

int Process::idx_i
protected

Index of first observation involved in split-merge move.

◆ idx_j

int Process::idx_j
protected

Index of second observation involved in split-merge move.

◆ log_a

const double Process::log_a = log(params.a)
protected

Precomputed logarithm of total mass parameter for efficiency.

◆ old_allocations

Eigen::VectorXi Process::old_allocations
protected

Storage for previous allocations to enable rollback in case of rejection.

◆ params

Params& Process::params
protected

Reference to the parameters object containing process hyperparameters.


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