Thesis docs
Loading...
Searching...
No Matches
DP Class Reference

Dirichlet Process class for Bayesian nonparametric clustering. More...

#include <DP.hpp>

Inheritance diagram for DP:
Process

Public Member Functions

 DP (Data &d, Params &p)
 Constructor for the Dirichlet Process.
 
void update_params () override
 Updates the parameters of the Dirichlet Process.
 
Gibbs Sampling Methods
double gibbs_prior_existing_cluster (int cls_idx, int obs_idx=0) const override
 Computes the log prior probability of assigning a data point to an existing cluster.
 
Eigen::VectorXd gibbs_prior_existing_clusters (int obs_idx) const override
 Computes the log prior probabilities of assigning a data point to all existing clusters.
 
double gibbs_prior_new_cluster () const override
 Computes the log prior probability of assigning a data point to a new cluster.
 
Split-Merge Algorithm Methods
double prior_ratio_split (int ci, int cj) const override
 Computes the prior ratio for a split operation in a split-merge MCMC algorithm.
 
double prior_ratio_merge (int size_old_ci, int size_old_cj) const override
 Computes the prior ratio for a merge operation in a split-merge MCMC algorithm.
 
double prior_ratio_shuffle (int size_old_ci, int size_old_cj, int ci, int cj) const override
 Computes the prior ratio for a shuffle operation in a split-merge MCMC algorithm.
 
- Public Member Functions inherited from Process
 Process (Data &d, Params &p)
 Constructor initializing process with data and parameters.
 
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 ~Process ()
 Virtual destructor for proper cleanup of derived classes.
 

Additional Inherited Members

- Protected Attributes inherited from Process
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

Dirichlet Process class for Bayesian nonparametric clustering.

This class implements a Dirichlet Process (DP) that inherits from the Process base class. It provides methods for Gibbs sampling and split-merge algorithms used in clustering.

Constructor & Destructor Documentation

◆ DP()

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

Constructor for the Dirichlet Process.

Parameters
dReference to the data object.
pReference to the parameters object.

Member Function Documentation

◆ gibbs_prior_existing_cluster()

double DP::gibbs_prior_existing_cluster ( int cls_idx,
int obs_idx = 0 ) const
nodiscardoverridevirtual

Computes the log prior probability of assigning a data point to an existing cluster.

Parameters
cls_idxThe index of the cluster.
obs_idxThe index of the observation (default: 0).
Returns
The log prior probability of assigning the data point to the existing cluster.

Computes the log prior probability of assigning a data point to an existing cluster.

Parameters
cls_idxThe index of the cluster.
obs_idxThe index of the observation (unused in this implementation).
Returns
The log prior probability of assigning the data point to its current cluster.

Implements Process.

◆ gibbs_prior_existing_clusters()

Eigen::VectorXd DP::gibbs_prior_existing_clusters ( int obs_idx) const
nodiscardoverridevirtual

Computes the log prior probabilities of assigning a data point to all existing clusters.

Parameters
obs_idxThe index of the observation.
Returns
A vector of log prior probabilities for all existing clusters.

Computes the log prior probabilities of assigning a data point to all existing clusters.

Parameters
obs_idxThe index of the observation (unused in this implementation).
Returns
A vector of log prior probabilities for all existing clusters.

Implements Process.

◆ gibbs_prior_new_cluster()

double DP::gibbs_prior_new_cluster ( ) const
nodiscardoverridevirtual

Computes the log prior probability of assigning a data point to a new cluster.

Returns
The log prior probability of assigning the data point to a new cluster.

Computes the log prior probability of assigning a data point to a new cluster.

Returns
The log prior probability of assigning the data point to a new cluster.

Implements Process.

◆ prior_ratio_merge()

double DP::prior_ratio_merge ( int size_old_ci,
int size_old_cj ) const
nodiscardoverridevirtual

Computes the prior ratio for a merge operation in a split-merge MCMC algorithm.

Parameters
size_old_ciThe size of the first cluster before the merge.
size_old_cjThe size of the second cluster before the merge.
Returns
The log prior ratio for the merge operation.

Computes the prior ratio for a merge operation in a split-merge MCMC algorithm.

Parameters
size_old_ciThe size of the first cluster before the merge.
size_old_cjThe size of the second cluster before the merge.
Returns
The log prior ratio for the merge operation.

Implements Process.

◆ prior_ratio_shuffle()

double DP::prior_ratio_shuffle ( int size_old_ci,
int size_old_cj,
int ci,
int cj ) const
nodiscardoverridevirtual

Computes the prior ratio for a shuffle operation in a split-merge MCMC algorithm.

Parameters
size_old_ciThe size of the first cluster before the shuffle.
size_old_cjThe size of the second cluster before the shuffle.
ciThe first cluster index involved in the shuffle.
cjThe second cluster index involved in the shuffle.
Returns
The log prior ratio for the shuffle operation.

Computes the prior ratio for a shuffle operation in a split-merge MCMC algorithm.

Parameters
size_old_ciThe size of the first cluster before the shuffle.
size_old_cjThe size of the second cluster before the shuffle.
ciThe first cluster index involved in the shuffle.
cjThe second cluster index involved in the shuffle.
Returns
The log prior ratio for the shuffle operation.

Implements Process.

◆ prior_ratio_split()

double DP::prior_ratio_split ( int ci,
int cj ) const
nodiscardoverridevirtual

Computes the prior ratio for a split operation in a split-merge MCMC algorithm.

Parameters
ciThe first cluster index involved in the split.
cjThe second cluster index involved in the split.
Returns
The log prior ratio for the split operation.

Computes the prior ratio for a split operation in a split-merge MCMC algorithm.

Parameters
ciThe first cluster index involved in the split.
cjThe second cluster index involved in the split.
Returns
The log prior ratio for the split operation.

Implements Process.

◆ update_params()

void DP::update_params ( )
inlineoverridevirtual

Updates the parameters of the Dirichlet Process.

This is a null implementation as the Dirichlet Process has no parameters to update.

Implements Process.


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