Thesis docs
Loading...
Searching...
No Matches
Process.hpp
Go to the documentation of this file.
1
13
14#pragma once
15
16#include "Data.hpp"
17#include "Params.hpp"
18#include <Eigen/Dense>
19#include <random>
20
41class Process {
42protected:
46
50
53 Eigen::VectorXi old_allocations;
54
56 int idx_i;
57
59 int idx_j;
60
62 const double log_a = log(params.a);
63
64public:
75 Process(Data &d, Params &p) : data(d), params(p) {
76 old_allocations = data.get_allocations();
77 };
78
79 // ========== Gibbs Sampling Methods ==========
80
93 virtual double gibbs_prior_existing_cluster(int cls_idx, int obs_idx) const = 0;
94
105
106 virtual Eigen::VectorXd gibbs_prior_existing_clusters(int obs_idx) const = 0;
107
117 virtual double gibbs_prior_new_cluster() const = 0;
118
119 // ========== Split-Merge Algorithm Methods ==========
120
131 virtual double prior_ratio_split(int ci, int cj) const = 0;
132
144 virtual double prior_ratio_merge(int size_old_ci, int size_old_cj) const = 0;
145
159 virtual double prior_ratio_shuffle(int size_old_ci, int size_old_cj, int ci,
160 int cj) const = 0;
161
162 // ========== State Management Methods ==========
163
172 void set_old_allocations(const Eigen::VectorXi &new_allocations) {
173 old_allocations = new_allocations;
174 };
175
181 void set_idx_i(int i) { idx_i = i; };
182
188 void set_idx_j(int j) { idx_j = j; };
189
190 // ========== Parameter Update Methods ==========
191
200 virtual void update_params() = 0;
201
205 virtual ~Process() {};
206};
Data structure for managing point distances and cluster allocations.
Parameter management for Bayesian nonparametric MCMC models.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:26
virtual double gibbs_prior_existing_cluster(int cls_idx, int obs_idx) const =0
Compute prior probability for assigning observation to existing cluster.
virtual double prior_ratio_split(int ci, int cj) const =0
Compute prior ratio for split move in split-merge algorithm.
const double log_a
Precomputed logarithm of total mass parameter for efficiency.
Definition Process.hpp:62
virtual double prior_ratio_shuffle(int size_old_ci, int size_old_cj, int ci, int cj) const =0
Compute prior ratio for shuffle move in split-merge algorithm.
virtual double prior_ratio_merge(int size_old_ci, int size_old_cj) const =0
Compute prior ratio for merge move in split-merge algorithm.
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
void set_old_allocations(const Eigen::VectorXi &new_allocations)
Store current allocations for potential rollback.
Definition Process.hpp:172
int idx_j
Index of second observation involved in split-merge move.
Definition Process.hpp:59
void set_idx_i(int i)
Set index of first observation in split-merge pair.
Definition Process.hpp:181
virtual ~Process()
Virtual destructor for proper cleanup of derived classes.
Definition Process.hpp:205
Eigen::VectorXi old_allocations
Storage for previous allocations to enable rollback in case of rejection.
Definition Process.hpp:53
int idx_i
Index of first observation involved in split-merge move.
Definition Process.hpp:56
void set_idx_j(int j)
Set index of second observation in split-merge pair.
Definition Process.hpp:188
virtual Eigen::VectorXd gibbs_prior_existing_clusters(int obs_idx) const =0
Compute prior probabilities for assigning observation to all existing clusters.
virtual void update_params()=0
Update process parameters during MCMC sampling.
virtual double gibbs_prior_new_cluster() const =0
Compute prior probability for creating a new cluster.
Data & data
Reference to the data object containing observations and allocations.
Definition Process.hpp:45
Structure containing all parameters needed for the NGGP (Normalized Generalized Gamma Process) and DP...
Definition Params.hpp:35