Docs
Loading...
Searching...
No Matches
NGGP.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
11#include "../utils/Process.hpp"
12
23class NGGP : public Process {
24
25protected:
30
32
43
48
50 std::random_device rd;
51
53 mutable std::mt19937 gen;
54
56
58 const double log_a = log(params.a);
59
60public:
71 : Process(d), params(p), gen(rd()), U_sampler_method(mh) {};
72
77
90 [[nodiscard]] double
91 gibbs_prior_existing_cluster(int cls_idx, int obs_idx = 0) const override;
92
102 [[nodiscard]] Eigen::VectorXd
103 gibbs_prior_existing_clusters(int obs_idx) const override;
104
114 [[nodiscard]] double gibbs_prior_new_cluster() const override;
115
117
122
133 [[nodiscard]] double prior_ratio_split(int ci, int cj) const override;
134
145 [[nodiscard]] double prior_ratio_merge(int size_old_ci,
146 int size_old_cj) const override;
147
160 [[nodiscard]] double prior_ratio_shuffle(int size_old_ci, int size_old_cj,
161 int ci, int cj) const override;
162
164
169
179 void update_params() override { U_sampler_method.update_U(); };
180
182};
Parameter management for models using NGG-process (Normalized Generalized Gamma Process).
Abstract interface for Bayesian nonparametric processes.
Base class for sampling the latent variable U in NGGP mixture models.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:26
std::mt19937 gen
Mersenne Twister random number generator.
Definition NGGP.hpp:53
U_sampler & U_sampler_method
Reference to the U_sampler instance for updating the latent variable U.
Definition NGGP.hpp:41
double prior_ratio_split(int ci, int cj) const override
Computes the prior ratio for a split operation in an NGGP-based split-merge MCMC algorithm.
Definition NGGP.cpp:75
double gibbs_prior_new_cluster() const override
Computes the log prior probability of assigning a data point to a new cluster.
Definition NGGP.cpp:62
void update_params() override
Updates the NGGP parameters by updating the latent variable U.
Definition NGGP.hpp:179
double prior_ratio_merge(int size_old_ci, int size_old_cj) const override
Computes the prior ratio for a merge operation in an NGGP-based split-merge MCMC algorithm.
Definition NGGP.cpp:104
NGGP(Data &d, NGGP_params &p, U_sampler &mh)
Constructor for the Normalized Generalized Gamma Process.
Definition NGGP.hpp:70
const NGGP_params & params
Definition NGGP.hpp:31
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 NGGP.cpp:16
const double log_a
Precomputed logarithm of total mass parameter for efficiency.
Definition NGGP.hpp:58
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 an NGGP-based split-merge MCMC algorithm.
Definition NGGP.cpp:131
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....
Definition NGGP.cpp:36
std::random_device rd
Random device for seeding.
Definition NGGP.hpp:50
Process(Data &d)
Constructor initializing process with data and parameters.
Definition Process.hpp:83
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