Dirichlet Process class for Bayesian nonparametric clustering.
More...
#include <DP.hpp>
|
| DP (Data &d, Params &p) |
| Constructor for the Dirichlet Process.
|
|
void | update_params () override |
| Updates the parameters of the Dirichlet Process.
|
|
|
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.
|
|
|
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.
|
|
| 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.
|
|
|
Data & | data |
| Reference to the data object containing observations and allocations.
|
|
Params & | params |
| 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.
|
|
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.
◆ DP()
Constructor for the Dirichlet Process.
- Parameters
-
d | Reference to the data object. |
p | Reference to the parameters object. |
◆ 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_idx | The index of the cluster. |
obs_idx | The 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_idx | The index of the cluster. |
obs_idx | The 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_idx | The 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_idx | The 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_ci | The size of the first cluster before the merge. |
size_old_cj | The 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_ci | The size of the first cluster before the merge. |
size_old_cj | The 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_ci | The size of the first cluster before the shuffle. |
size_old_cj | The size of the second cluster before the shuffle. |
ci | The first cluster index involved in the shuffle. |
cj | The 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_ci | The size of the first cluster before the shuffle. |
size_old_cj | The size of the second cluster before the shuffle. |
ci | The first cluster index involved in the shuffle. |
cj | The 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
-
ci | The first cluster index involved in the split. |
cj | The 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
-
ci | The first cluster index involved in the split. |
cj | The 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: