Thesis docs
Loading...
Searching...
No Matches
NGGPW.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
10
21class NGGPW : public Process {
22
23private:
28
30 double U = 1;
31
33 double tau = params.tau;
34
36
41
45 void update_U();
46
53 double log_conditional_density_V(double v) const;
54
56
61
63 std::random_device rd;
64
66 mutable std::mt19937 gen;
67
69
74
77 static constexpr double proposal_std = 0.5;
78
80
86
88 const double a_over_sigma = params.a / params.sigma;
89
91 const double tau_power_sigma = std::pow(params.tau, params.sigma);
92
94
99
101 int accepted_U = 0;
102
104
105public:
114 NGGPW(Data &d, Params &p) : Process(d, p), gen(rd()) {};
115
120
132 [[nodiscard]] double
133 gibbs_prior_existing_cluster(int cls_idx, int obs_idx = 0) const override;
134
142 [[nodiscard]] Eigen::VectorXd gibbs_prior_existing_clusters(int obs_idx) const override;
143
153 [[nodiscard]] double gibbs_prior_new_cluster() const override;
154
156
161
173 [[nodiscard]] double prior_ratio_split(int ci, int cj) const override;
174
186 [[nodiscard]] double prior_ratio_merge(int size_old_ci,
187 int size_old_cj) const override;
188
202 [[nodiscard]] double prior_ratio_shuffle(int size_old_ci, int size_old_cj,
203 int ci, int cj) const override;
204
206
211
223 int get_neighbors_obs(int obs_idx, int cls_idx) const;
224
233 Eigen::VectorXi get_neighbors_obs(int obs_idx) const;
234
246 int get_neighbors_cls(int cls_idx, bool old_allo = false) const;
247
249
254
258 void update_params() override { update_U(); };
259
261
266
271 double get_U() const { return U; }
272
277 int get_accepted_U() const { return accepted_U; }
278
280};
Abstract interface for Bayesian nonparametric processes.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:26
void update_params() override
Updates the NGGPW parameters by updating the latent variable U.
Definition NGGPW.hpp:258
int get_neighbors_obs(int obs_idx, int cls_idx) const
Returns the number of neighbors for a given observation in a specific cluster.
Definition NGGPW.cpp:16
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 NGGPW.cpp:86
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 NGGPW.cpp:145
double gibbs_prior_new_cluster() const override
Computes the log prior probability of assigning a data point to a new cluster.
Definition NGGPW.cpp:131
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 NGGPW.cpp:177
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 NGGPW.cpp:211
double get_U() const
Gets the current value of the latent variable U.
Definition NGGPW.hpp:271
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 NGGPW.cpp:112
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.
Definition NGGPW.cpp:43
NGGPW(Data &d, Params &p)
Constructor for the Normalized Generalized Gamma Process with spatial Weights.
Definition NGGPW.hpp:114
int get_accepted_U() const
Gets the number of accepted U updates for monitoring convergence.
Definition NGGPW.hpp:277
Process(Data &d, Params &p)
Constructor initializing process with data and parameters.
Definition Process.hpp:75
Params & params
Reference to the parameters object containing process hyperparameters.
Definition Process.hpp:49
Structure containing all parameters needed for the NGGP (Normalized Generalized Gamma Process) and DP...
Definition Params.hpp:35