Docs
Loading...
Searching...
No Matches
MALA.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
9#include "U_sampler.hpp"
10
30class MALA : public U_sampler {
31
32private:
34 double epsilon = 1.0;
35
38 double old_epsilon = 1.0;
39
49 double grad_log_conditional_density_U(double U) const;
50
61 double grad_log_conditional_density_V(double v) const;
62
64 bool accept = false;
65
74 void sampling_U();
75
86 void sampling_V();
87
90 bool use_V = false;
91
94 bool tuning_enabled = false;
95
119
126 int BI_adapt = 5 / (0.574 * (1 - 0.574));
127
128public:
140 MALA(NGGP_params &p, Data &d, bool use_V = false, double eps = 1,
141 bool tuning = false)
142 : U_sampler(p, d), epsilon(eps), old_epsilon(epsilon),
143 tuning_enabled(tuning), use_V(use_V) {};
144
155 void update_U() override;
156};
Base class for sampling the latent variable U in NGGP mixture models.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:26
void sampling_V()
Samples U using MALA on the transformed V = log(U) scale.
Definition MALA.cpp:24
void sampling_U()
Samples U using MALA on the original U scale.
Definition MALA.cpp:92
void update_U() override
Performs one MALA update step for the latent variable U.
Definition MALA.cpp:9
double grad_log_conditional_density_V(double v) const
Computes the gradient of log conditional density with respect to V = log(U).
Definition MALA.cpp:80
double old_epsilon
Previous value of epsilon, used for restart mechanism in adaptive tuning.
Definition MALA.hpp:38
void Robbins_Monro_tuning()
Performs Robbins-Monro tuning of the proposal step size epsilon.
Definition MALA.cpp:151
int BI_adapt
Number of initial iterations before adaptive tuning begins.
Definition MALA.hpp:126
double epsilon
Step size parameter for the Langevin dynamics proposal.
Definition MALA.hpp:34
bool use_V
Flag to use V = log(U) transformation instead of direct U sampling.
Definition MALA.hpp:90
bool tuning_enabled
Flag to enable/disable Robbins-Monro adaptive tuning of step size.
Definition MALA.hpp:94
double grad_log_conditional_density_U(double U) const
Computes the gradient of log conditional density with respect to U.
Definition MALA.cpp:138
MALA(NGGP_params &p, Data &d, bool use_V=false, double eps=1, bool tuning=false)
Constructor for MALA sampler.
Definition MALA.hpp:140
bool accept
Flag indicating whether the last proposal was accepted.
Definition MALA.hpp:64
U_sampler(NGGP_params &p, Data &d)
Constructor for the U_sampler class.
Definition U_sampler.hpp:154
double U
Current value of the latent variable U (initialized to 1.0).
Definition U_sampler.hpp:66
Struct for storing parameters of the NGGP (Normalized Generalized Gamma Process).
Definition NGGP-params.hpp:28