Docs
Loading...
Searching...
No Matches
DPx.hpp
Go to the documentation of this file.
1
11
12#pragma once
13
14#include "DP.hpp"
15#include "../utils/Module.hpp"
16#include <memory>
17
26
27class DPx : public DP {
28
29protected:
30 std::vector<std::shared_ptr<Module>> modules;
31
32public:
41 DPx(Data &d, Params &p, const std::vector<std::shared_ptr<Module>> &mods) : DP(d, p), modules(mods) {
42 for (auto &mod : modules) {
43 mod->set_old_allocations_provider(&this->old_allocations_view());
44 mod->set_old_cluster_members_provider(&this->old_cluster_members_view());
45 }
46 }
47
52
64 [[nodiscard]] double gibbs_prior_existing_cluster(int cls_idx, int obs_idx) const override;
65
73 [[nodiscard]] Eigen::VectorXd gibbs_prior_existing_clusters(int obs_idx) const override;
74
81 [[nodiscard]] double gibbs_prior_new_cluster() const override;
82
93 [[nodiscard]] double gibbs_prior_new_cluster_obs(int obs_idx) const override;
94
96
101
111 [[nodiscard]] double prior_ratio_split(int ci, int cj) const override;
112
122 [[nodiscard]] double prior_ratio_merge(int size_old_ci, int size_old_cj) const override;
123
136 [[nodiscard]] double prior_ratio_shuffle(int size_old_ci, int size_old_cj, int ci, int cj) const override;
137
139
146 void update_params() override { return; };
147};
Dirichlet Process implementation for Bayesian nonparametric clustering.
Base class for modules used in processes.
DP(Data &d, Params &p)
Constructor for the Dirichlet Process.
Definition DP.hpp:27
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 split-merge MCMC.
Definition DPx.cpp:111
double prior_ratio_split(int ci, int cj) const override
Computes the prior ratio for a split operation in split-merge MCMC.
Definition DPx.cpp:61
void update_params() override
Updates the module-based parameters.
Definition DPx.hpp:146
std::vector< std::shared_ptr< Module > > modules
Definition DPx.hpp:30
double gibbs_prior_new_cluster_obs(int obs_idx) const override
Observation-specific new-cluster prior.
Definition DPx.cpp:51
DPx(Data &d, Params &p, const std::vector< std::shared_ptr< Module > > &mods)
Constructor for the Dirichlet Process with modules.
Definition DPx.hpp:41
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 DPx.cpp:16
double gibbs_prior_existing_cluster(int cls_idx, int obs_idx) const override
Computes the log prior probability of assigning a data point to an existing cluster.
Definition DPx.cpp:39
double prior_ratio_merge(int size_old_ci, int size_old_cj) const override
Computes the prior ratio for a merge operation in split-merge MCMC.
Definition DPx.cpp:83
double gibbs_prior_new_cluster() const override
Computes the log prior probability of assigning a data point to a new cluster.
Definition DPx.cpp:49
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:27
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
Structure containing all parameters needed for the NGGP (Normalized Generalized Gamma Process) and DP...
Definition Params.hpp:35