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

Normalized Generalized Gamma Process with spatial Weights class for spatially-aware Bayesian nonparametric clustering. More...

#include <NGGPW.hpp>

Inheritance diagram for NGGPW:
Process

Public Member Functions

 NGGPW (Data &d, Params &p)
 Constructor for the Normalized Generalized Gamma Process with spatial Weights.
 
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 every existing cluster. This method is useful for Gibbs sampling over existing clusters. It returns a vector of log prior probabilities for 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 spatially-aware NGGP-based 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 spatially-aware NGGP-based 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 spatially-aware NGGP-based split-merge MCMC algorithm.
 
Spatial Methods
int get_neighbors_obs (int obs_idx, int cls_idx) const
 Returns the number of neighbors for a given observation in a specific cluster.
 
Eigen::VectorXi get_neighbors_obs (int obs_idx) const
 Returns the number of neighbors for a given observation regardless of cluster membership. This method counts the total number of neighbors of an observation based on the adjacency matrix W.
 
int get_neighbors_cls (int cls_idx, bool old_allo=false) const
 Returns the total number of neighbors for all observations in a given cluster.
 
Parameter Update Methods
void update_params () override
 Updates the NGGPW parameters by updating the latent variable U.
 
Accessor Methods
double get_U () const
 Gets the current value of the latent variable U.
 
int get_accepted_U () const
 Gets the number of accepted U updates for monitoring convergence.
 
- 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

Normalized Generalized Gamma Process with spatial Weights class for spatially-aware Bayesian nonparametric clustering.

This class extends the Normalized Generalized Gamma Process (NGGP) to incorporate spatial information through an adjacency matrix W. It combines the flexibility of the NGGP in modeling cluster sizes with spatial dependencies between observations.

Constructor & Destructor Documentation

◆ NGGPW()

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

Constructor for the Normalized Generalized Gamma Process with spatial Weights.

Parameters
dReference to the data object containing observations and cluster assignments.
pReference to the parameters object containing NGGP parameters (a, sigma, tau) and spatial information (W, coefficient).

Member Function Documentation

◆ get_accepted_U()

int NGGPW::get_accepted_U ( ) const
inline

Gets the number of accepted U updates for monitoring convergence.

Returns
The number of accepted U updates.

◆ get_neighbors_cls()

int NGGPW::get_neighbors_cls ( int cls_idx,
bool old_allo = false ) const

Returns the total number of neighbors for all observations in a given cluster.

This method computes the sum of all neighbor connections within a cluster, which is used in the spatial component of the prior calculations.

Parameters
cls_idxThe index of the cluster.
old_alloIf true, uses the old allocations for neighbor counting; otherwise, uses current allocations (default: false).
Returns
The total number of neighbors for the cluster.

Returns the total number of neighbors for all observations in a given cluster.

This method computes the sum of all neighbor connections within a cluster, which is used in the spatial component of the prior calculations.

Parameters
cls_idxThe index of the cluster.
old_alloIf true, uses the old allocations for neighbor counting; otherwise, uses current allocations.
Returns
The total number of neighbors for the cluster.

◆ get_neighbors_obs() [1/2]

Eigen::VectorXi NGGPW::get_neighbors_obs ( int obs_idx) const

Returns the number of neighbors for a given observation regardless of cluster membership. This method counts the total number of neighbors of an observation based on the adjacency matrix W.

Parameters
obs_idxThe index of the observation.
Returns
The total number of neighbors for the observation for all clusters.

Returns the number of neighbors for a given observation regardless of cluster membership. This method counts the total number of neighbors of an observation based on the adjacency matrix W.

Parameters
obs_idxThe index of the observation.
Returns
The total number of neighbors for the observation for all clusters.

◆ get_neighbors_obs() [2/2]

int NGGPW::get_neighbors_obs ( int obs_idx,
int cls_idx ) const

Returns the number of neighbors for a given observation in a specific cluster.

This method counts the neighbors of an observation based on the adjacency matrix W, considering only neighbors that belong to the specified cluster.

Parameters
obs_idxThe index of the observation.
cls_idxThe index of the cluster to consider for neighbor counting.
Returns
The number of neighbors for the observation in the specified cluster.

Returns the number of neighbors for a given observation in a specific cluster.

This method counts the neighbors of an observation based on the adjacency matrix W, considering only neighbors that belong to the specified cluster.

Parameters
obs_idxThe index of the observation.
cls_idxThe index of the cluster to consider for neighbor counting.
Returns
The number of neighbors for the observation in the specified cluster.

◆ get_U()

double NGGPW::get_U ( ) const
inline

Gets the current value of the latent variable U.

Returns
The current value of U.

◆ gibbs_prior_existing_cluster()

double NGGPW::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.

For NGGPW, this combines the NGGP discount parameter (n_k - sigma) with spatial information from the adjacency matrix W.

Parameters
cls_idxThe index of the cluster.
obs_idxThe index of the observation to assign.
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.

For NGGPW, this combines the NGGP discount parameter (n_k - sigma) with spatial information from the adjacency matrix W.

Parameters
cls_idxThe index of the cluster.
obs_idxThe index of the observation to assign.
Returns
The log prior probability of assigning the data point to the existing cluster.

Implements Process.

◆ gibbs_prior_existing_clusters()

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

Computes the log prior probabilities of assigning a data point to every existing cluster. This method is useful for Gibbs sampling over existing clusters. It returns a vector of log prior probabilities for all existing clusters.

Parameters
obs_idxThe index of the observation to assign.
Returns
A vector of log prior probabilities for assigning the data point to each existing cluster.

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

This method incorporates spatial information by considering the number of neighbors in each target cluster when computing the prior probabilities.

Parameters
obs_idxThe index of the observation to assign.
Returns
A vector of log prior probabilities for assigning the data point to each existing cluster.

Implements Process.

◆ gibbs_prior_new_cluster()

double NGGPW::gibbs_prior_new_cluster ( ) const
nodiscardoverridevirtual

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

For NGGPW, this follows the NGGP formulation and is proportional to alpha * sigma * (tau + U)^sigma.

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.

For NGGPW, this follows the NGGP formulation and is proportional to alpha * sigma * (tau + U)^sigma. New clusters have zero spatial neighbors.

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

Implements Process.

◆ prior_ratio_merge()

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

Computes the prior ratio for a merge operation in a spatially-aware NGGP-based split-merge MCMC algorithm.

This method accounts for both the generalized gamma process prior and spatial dependencies when computing the acceptance ratio for merging clusters.

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 spatially-aware NGGP-based split-merge MCMC algorithm.

This method accounts for both the generalized gamma process prior and spatial dependencies when computing the acceptance ratio for merging clusters.

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 NGGPW::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 spatially-aware NGGP-based split-merge MCMC algorithm.

This method accounts for both the generalized gamma process prior and spatial dependencies when computing the acceptance ratio for shuffling observations between clusters.

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 spatially-aware NGGP-based split-merge MCMC algorithm.

This method accounts for both the generalized gamma process prior and spatial dependencies when computing the acceptance ratio for shuffling observations between clusters.

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 NGGPW::prior_ratio_split ( int ci,
int cj ) const
nodiscardoverridevirtual

Computes the prior ratio for a split operation in a spatially-aware NGGP-based split-merge MCMC algorithm.

This method accounts for both the generalized gamma process prior and spatial dependencies when computing the acceptance ratio for splitting clusters.

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 spatially-aware NGGP-based split-merge MCMC algorithm.

This method accounts for both the generalized gamma process prior and spatial dependencies when computing the acceptance ratio for splitting clusters.

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 NGGPW::update_params ( )
inlineoverridevirtual

Updates the NGGPW parameters by updating the latent variable U.

Implements Process.


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