|
| | Process (Data &d, const 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 | gibbs_prior_new_cluster_obs (int obs_idx) const |
| | Compute prior probability for creating a new cluster for a specific observation.
|
| 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_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 void | update_params ()=0 |
| | Update process parameters during MCMC sampling.
|
| virtual | ~Process () |
| | Virtual destructor for proper cleanup of derived classes.
|
|
| 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.
|
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
| 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_idx | Index of the existing cluster |
| obs_idx | Index 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, DPx, NGGP, and NGGPx.
| 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_idx | Index 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, DPx, NGGP, and NGGPx.
| 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, DPx, NGGP, and NGGPx.
| virtual double Process::gibbs_prior_new_cluster_obs |
( |
int | obs_idx | ) |
const |
|
inlinevirtual |
Compute prior probability for creating a new cluster for a specific observation.
- Parameters
-
| obs_idx | Index of the observation being (re)assigned. |
- Returns
- Log prior probability of assigning obs_idx to a new cluster.
Some models (e.g., PPMx covariate similarity) add an observation-dependent term to the "new cluster" option. By default, this falls back to the observation-agnostic prior returned by gibbs_prior_new_cluster().
Reimplemented in DPx, and NGGPx.
| 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_ci | Size of first cluster before merge |
| size_old_cj | Size 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, DPx, NGGP, and NGGPx.
| 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_ci | Size of first cluster before shuffle |
| size_old_cj | Size of second cluster before shuffle |
| ci | Index of first cluster after shuffle |
| cj | Index 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, DPx, NGGP, and NGGPx.
| virtual double Process::prior_ratio_split |
( |
int | ci, |
|
|
int | cj ) const |
|
pure virtual |
Compute prior ratio for split move in split-merge algorithm.
- Parameters
-
| ci | Index of first resulting cluster after split |
| cj | Index 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, DPx, NGGP, and NGGPx.
| 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, DPx, NGGP, and NGGPx.