Docs
Loading...
Searching...
No Matches
NGGPx.hpp
Go to the documentation of this file.
1
11
12#pragma once
13
14#include "NGGP.hpp"
15#include "../utils/Module.hpp"
16#include <vector>
17#include <memory>
18
27
28class NGGPx : public NGGP {
29
30protected:
31 std::vector<std::shared_ptr<Module>> modules;
32
33public:
42 NGGPx(Data &d, Params &p, U_sampler &U_sam, const std::vector<std::shared_ptr<Module>> &mods)
43 : NGGP(d, p, U_sam), modules(mods) {
44 for (auto &mod : modules) {
45 mod->set_old_allocations_provider(&this->old_allocations_view());
46 mod->set_old_cluster_members_provider(&this->old_cluster_members_view());
47 }
48 }
49
54
67 [[nodiscard]] double gibbs_prior_existing_cluster(int cls_idx, int obs_idx = 0) const override;
68
76 [[nodiscard]] Eigen::VectorXd gibbs_prior_existing_clusters(int obs_idx) const override;
77
87 [[nodiscard]] double gibbs_prior_new_cluster() const override;
88
99 [[nodiscard]] double gibbs_prior_new_cluster_obs(int obs_idx) const override;
100
102
107
119 [[nodiscard]] double prior_ratio_split(int ci, int cj) const override;
120
132 [[nodiscard]] double prior_ratio_merge(int size_old_ci, int size_old_cj) const override;
133
147 [[nodiscard]] double prior_ratio_shuffle(int size_old_ci, int size_old_cj, int ci, int cj) const override;
148
150
155
164 void update_params() override { NGGP::U_sampler_method.update_U(); };
165
167};
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:27
U_sampler & U_sampler_method
Reference to the U_sampler instance for updating the latent variable U.
Definition NGGP.hpp:38
NGGP(Data &d, Params &p, U_sampler &mh)
Constructor for the Normalized Generalized Gamma Process.
Definition NGGP.hpp:64
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, Params &p, U_sampler &U_sam, const std::vector< std::shared_ptr< Module > > &mods)
Construct an NGGPWx process.
Definition NGGPx.hpp:42
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:86
std::vector< std::shared_ptr< Module > > modules
Definition NGGPx.hpp:31
void update_params() override
Update process parameters.
Definition NGGPx.hpp:164
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:237
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:67
Abstract base class for MCMC sampling of the latent variable U.
Definition U_sampler.hpp:28
Structure containing all parameters needed for the NGGP (Normalized Generalized Gamma Process) and DP...
Definition Params.hpp:35