Docs
Loading...
Searching...
No Matches
NGGPx.hpp
Go to the documentation of this file.
1
12
13#pragma once
14
15#include "../utils/Module.hpp"
16#include "NGGP.hpp"
17#include <memory>
18#include <vector>
19
29
30class NGGPx : public NGGP {
31
32protected:
33 std::vector<std::shared_ptr<Module>> modules;
34
35public:
45 const std::vector<std::shared_ptr<Module>> &mods)
46 : NGGP(d, p, U_sam), modules(mods) {
47 for (auto &mod : modules) {
48 mod->set_old_allocations_provider(&this->old_allocations_view());
49 mod->set_old_cluster_members_provider(&this->old_cluster_members_view());
50 }
51 }
52
57
71 [[nodiscard]] double
72 gibbs_prior_existing_cluster(int cls_idx, int obs_idx = 0) const override;
73
82 [[nodiscard]] Eigen::VectorXd
83 gibbs_prior_existing_clusters(int obs_idx) const override;
84
94 [[nodiscard]] double gibbs_prior_new_cluster() const override;
95
106 [[nodiscard]] double gibbs_prior_new_cluster_obs(int obs_idx) const override;
107
109
114
126 [[nodiscard]] double prior_ratio_split(int ci, int cj) const override;
127
139 [[nodiscard]] double prior_ratio_merge(int size_old_ci,
140 int size_old_cj) const override;
141
155 [[nodiscard]] double prior_ratio_shuffle(int size_old_ci, int size_old_cj,
156 int ci, int cj) const override;
157
159
164
173 void update_params() override { NGGP::U_sampler_method.update_U(); };
174
176};
Base class for modules used in processes.
Normalized Generalized Gamma Process (NGGP) implementation for Bayesian nonparametric clustering.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:26
U_sampler & U_sampler_method
Reference to the U_sampler instance for updating the latent variable U.
Definition NGGP.hpp:41
NGGP(Data &d, NGGP_params &p, U_sampler &mh)
Constructor for the Normalized Generalized Gamma Process.
Definition NGGP.hpp:70
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 algor...
Definition NGGPx.cpp:65
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.
Definition NGGPx.cpp:15
double gibbs_prior_new_cluster_obs(int obs_idx) const override
Observation-specific new-cluster prior.
Definition NGGPx.cpp:42
NGGPx(Data &d, NGGP_params &p, U_sampler &U_sam, const std::vector< std::shared_ptr< Module > > &mods)
Construct an NGGPWx process.
Definition NGGPx.hpp:44
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 alg...
Definition NGGPx.cpp:85
std::vector< std::shared_ptr< Module > > modules
Definition NGGPx.hpp:33
void update_params() override
Update process parameters.
Definition NGGPx.hpp:173
double gibbs_prior_new_cluster() const override
Computes the log prior probability of assigning a data point to a new cluster.
Definition NGGPx.cpp:40
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 algor...
Definition NGGPx.cpp:52
Eigen::VectorXd gibbs_prior_existing_clusters(int obs_idx) const override
Computes the log prior for assigning an observation to each existing cluster.
Definition NGGPx.cpp:28
const Eigen::VectorXi & old_allocations_view() const
Provides read-only access to the stored previous allocations.
Definition Process.hpp:236
const std::unordered_map< int, std::vector< int > > & old_cluster_members_view() const
Provides read-only access to the stored previous cluster members.
Definition Process.hpp:63
Abstract base class for MCMC sampling of the latent variable U.
Definition U_sampler.hpp:28
Struct for storing parameters of the NGGP (Normalized Generalized Gamma Process).
Definition NGGP-params.hpp:28