Docs
Loading...
Searching...
No Matches
neal_ZDNAM.hpp
Go to the documentation of this file.
1
14
15#pragma once
16
17#include "../utils/Sampler.hpp"
18
60class Neal3ZDNAM : public Sampler {
61private:
62 // ========== Random Number Generation ==========
63
65 mutable std::mt19937 gen;
66
67 // ========== Core Algorithm Methods ==========
68
91 void step_1_observation(int index);
92
106 int sample_from_log_probs(const std::vector<double> &log_probs);
107
146 std::vector<double>
147 compute_zdnam_probabilities(const std::vector<double> &log_probs,
148 int current_k);
149
174 int sample_from_log_probs_zdnam(const std::vector<double> &log_probs,
175 int current_k);
176
177public:
178 // ========== Constructor ==========
179
200 : Sampler(d, p, l, pr), gen(rd()) {};
201
202 // ========== MCMC Interface ==========
203
233 void step() override;
234};
Abstract base class for MCMC sampling algorithms.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:27
Abstract base class for likelihood computation.
Definition Likelihood.hpp:27
std::mt19937 gen
Mersenne Twister random number generator for sampling operations.
Definition neal_ZDNAM.hpp:65
void step() override
Perform one complete iteration of Neal's Algorithm 3 with ZDNAM.
Definition neal_ZDNAM.cpp:229
void step_1_observation(int index)
Update cluster assignment for a single observation using ZDNAM.
Definition neal_ZDNAM.cpp:194
int sample_from_log_probs(const std::vector< double > &log_probs)
Sample from log probabilities using standard Gibbs sampling.
std::vector< double > compute_zdnam_probabilities(const std::vector< double > &log_probs, int current_k)
Compute ZDNAM transition probabilities from current state.
Definition neal_ZDNAM.cpp:17
int sample_from_log_probs_zdnam(const std::vector< double > &log_probs, int current_k)
Sample from log probabilities using ZDNAM to avoid self-transitions.
Definition neal_ZDNAM.cpp:151
Neal3ZDNAM(Data &d, Params &p, Likelihood &l, Process &pr)
Constructor for Neal's Algorithm 3 with ZDNAM sampler.
Definition neal_ZDNAM.hpp:199
Abstract base class for Bayesian nonparametric processes.
Definition Process.hpp:41
Sampler(Data &d, const Params &p, const Likelihood &l, Process &pr)
Constructor initializing sampler with required components.
Definition Sampler.hpp:97
std::random_device rd
Random device for generating random numbers across sampling algorithms.
Definition Sampler.hpp:73
Structure containing all parameters needed for the NGGP (Normalized Generalized Gamma Process) and DP...
Definition Params.hpp:35