|
Docs
|
Dirichlet Process class for Bayesian nonparametric clustering. More...
#include <DP.hpp>
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, const Params &p) | |
| Constructor initializing process with data and parameters. | |
| virtual double | gibbs_prior_new_cluster_obs (int obs_idx) const |
| Compute prior probability for creating a new cluster for a specific observation. | |
| void | set_old_allocations (const Eigen::VectorXi &new_allocations) |
| Store current allocations for potential rollback. | |
| void | set_old_cluster_members (const std::unordered_map< int, std::vector< int > > &new_cluster_members) |
| Store current cluster members for potential rollback. | |
| void | set_old_K (int new_K) |
| Store current number of clusters for potential rollback. | |
| void | restore_state () |
| Restores the cached state into the data object. | |
| const Eigen::VectorXi & | old_allocations_view () const |
| Provides read-only access to the stored previous allocations. | |
| 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 Member Functions inherited from Process | |
| const std::unordered_map< int, std::vector< int > > & | old_cluster_members_view () const |
| Provides read-only access to the stored previous cluster members. | |
| Protected Attributes inherited from Process | |
| Data & | data |
| Reference to the data object containing observations and allocations. | |
| const 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 or for computation requiring it. | |
| std::unordered_map< int, std::vector< int > > | old_cluster_members |
| Storage for previous cluster members to enable rollback in case of rejection or for computation requiring it. | |
| int | old_K = 0 |
| Number of clusters associated with the stored previous state. | |
| 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.
Constructor for the Dirichlet Process.
| d | Reference to the data object. |
| p | Reference to the parameters object. |
|
nodiscardoverridevirtual |
Computes the log prior probability of assigning a data point to an existing cluster.
| cls_idx | The index of the cluster. |
| obs_idx | The index of the observation (default: 0). |
Computes the log prior probability of assigning a data point to an existing cluster.
| cls_idx | The index of the cluster. |
| obs_idx | The index of the observation (unused in this implementation). |
Implements Process.
Reimplemented in DPx.
|
nodiscardoverridevirtual |
Computes the log prior probabilities of assigning a data point to all existing clusters.
| obs_idx | The index of the observation. |
Computes the log prior probabilities of assigning a data point to all existing clusters.
| obs_idx | The index of the observation (unused in this implementation). |
Implements Process.
Reimplemented in DPx.
|
nodiscardoverridevirtual |
Computes the log prior probability of assigning a data point to a new cluster.
Computes the log prior probability of assigning a data point to a new cluster.
Implements Process.
Reimplemented in DPx.
|
nodiscardoverridevirtual |
Computes the prior ratio for a merge operation in a split-merge MCMC algorithm.
| size_old_ci | The size of the first cluster before the merge. |
| size_old_cj | The size of the second cluster before the merge. |
Computes the prior ratio for a merge operation in a split-merge MCMC algorithm.
| size_old_ci | The size of the first cluster before the merge. |
| size_old_cj | The size of the second cluster before the merge. |
Implements Process.
Reimplemented in DPx.
|
nodiscardoverridevirtual |
Computes the prior ratio for a shuffle operation in a split-merge MCMC algorithm.
| 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. |
Computes the prior ratio for a shuffle operation in a split-merge MCMC algorithm.
| 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. |
Implements Process.
Reimplemented in DPx.
|
nodiscardoverridevirtual |
Computes the prior ratio for a split operation in a split-merge MCMC algorithm.
| ci | The first cluster index involved in the split. |
| cj | The second cluster index involved in the split. |
Computes the prior ratio for a split operation in a split-merge MCMC algorithm.
| ci | The first cluster index involved in the split. |
| cj | The second cluster index involved in the split. |
Implements Process.
Reimplemented in DPx.
|
inlineoverridevirtual |