Docs
Loading...
Searching...
No Matches
MALA.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "U_sampler.hpp"
9
29class MALA : public U_sampler {
30
31private:
33 double epsilon = 1.0;
34
37 double old_epsilon = 1.0;
38
48 double grad_log_conditional_density_U(double U) const;
49
60 double grad_log_conditional_density_V(double v) const;
61
63 bool accept = false;
64
73 void sampling_U();
74
85 void sampling_V();
86
89 bool use_V = false;
90
93 bool tuning_enabled = false;
94
118
125 int BI_adapt = 5 / (0.574 * (1 - 0.574));
126
127public:
139 MALA(Params &p, Data &d, bool use_V = false, double eps = 1,
140 bool tuning = false)
141 : U_sampler(p, d), epsilon(eps), old_epsilon(epsilon),
142 tuning_enabled(tuning) {};
143
154 void update_U() override;
155};
Base class for sampling the latent variable U in NGGP mixture models.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:27
void sampling_V()
Samples U using MALA on the transformed V = log(U) scale.
Definition MALA.cpp:23
void sampling_U()
Samples U using MALA on the original U scale.
Definition MALA.cpp:91
void update_U() override
Performs one MALA update step for the latent variable U.
Definition MALA.cpp:8
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:79
double old_epsilon
Previous value of epsilon, used for restart mechanism in adaptive tuning.
Definition MALA.hpp:37
void Robbins_Monro_tuning()
Performs Robbins-Monro tuning of the proposal step size epsilon.
Definition MALA.cpp:150
int BI_adapt
Number of initial iterations before adaptive tuning begins.
Definition MALA.hpp:125
double epsilon
Step size parameter for the Langevin dynamics proposal.
Definition MALA.hpp:33
MALA(Params &p, Data &d, bool use_V=false, double eps=1, bool tuning=false)
Constructor for MALA sampler.
Definition MALA.hpp:139
bool use_V
Flag to use V = log(U) transformation instead of direct U sampling.
Definition MALA.hpp:89
bool tuning_enabled
Flag to enable/disable Robbins-Monro adaptive tuning of step size.
Definition MALA.hpp:93
double grad_log_conditional_density_U(double U) const
Computes the gradient of log conditional density with respect to U.
Definition MALA.cpp:137
bool accept
Flag indicating whether the last proposal was accepted.
Definition MALA.hpp:63
U_sampler(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
Structure containing all parameters needed for the NGGP (Normalized Generalized Gamma Process) and DP...
Definition Params.hpp:35