79 mutable std::mt19937
gen;
196 bool sequential =
true);
296 int old_ci_size,
int old_cj_size);
329 for (
int i = 0; i <
data.get_n(); ++i) {
332 const int n =
data.get_n();
335 std::vector<double> pairwise_dists;
336 pairwise_dists.reserve(n * (n - 1) / 2);
337 for (
int i = 0; i < n; ++i) {
338 for (
int j = i + 1; j < n; ++j) {
339 pairwise_dists.push_back(
params.D(i, j));
344 if (!pairwise_dists.empty()) {
345 auto q_it = pairwise_dists.begin() +
346 static_cast<size_t>(pairwise_dists.size() * 0.50);
347 std::nth_element(pairwise_dists.begin(), q_it, pairwise_dists.end());
349 if (temperature < 1e-12)
384 void step() override final;
Abstract base class for MCMC sampling algorithms.
Manages distance matrices and cluster allocations for points.
Definition Data.hpp:26
Abstract base class for likelihood computation.
Definition Likelihood.hpp:26
Abstract base class for Bayesian nonparametric processes.
Definition Process.hpp:40
Data & data
Reference to the data object containing observations and current allocations.
Definition Sampler.hpp:53
std::random_device rd
Random device for generating random numbers across sampling algorithms.
Definition Sampler.hpp:67
Sampler(Data &d, const Likelihood &l, Process &pr)
Constructor initializing sampler with required components.
Definition Sampler.hpp:89
const utils_params & params
Definition splitmerge_LSS_SDDS.hpp:70
std::uniform_int_distribution dis_int
uniform integer distribution for general use
Definition splitmerge_LSS_SDDS.hpp:121
int ci
Cluster assignment of first observation.
Definition splitmerge_LSS_SDDS.hpp:90
int split_moves
Definition splitmerge_LSS_SDDS.hpp:148
void step() override final
Perform one iteration of the LSS-SDDS Split-Merge algorithm.
Definition splitmerge_LSS_SDDS.cpp:406
std::uniform_real_distribution dis_real
uniform distribution between 0 and 1
Definition splitmerge_LSS_SDDS.hpp:118
int shuffle_moves
Definition splitmerge_LSS_SDDS.hpp:150
double temperature
Definition splitmerge_LSS_SDDS.hpp:73
void dumb_split_move()
Execute a dumb split move with random allocation.
Definition splitmerge_LSS_SDDS.cpp:271
Eigen::Vector2d log_probs
Log probabilities of allocating a point to clusters ci and cj.
Definition splitmerge_LSS_SDDS.hpp:126
double compute_acceptance_ratio_split(double likelihood_old_cluster)
Compute acceptance ratio for LSS split move.
Definition splitmerge_LSS_SDDS.cpp:301
SplitMerge_LSS_SDDS(Data &d, utils_params &p, Likelihood &l, Process &pr, bool shuffle)
Constructor for LSS-SDDS (Locality Sensitive Sampling with Smart-split, Dumb-merge,...
Definition splitmerge_LSS_SDDS.hpp:321
int accepted_merge
Definition splitmerge_LSS_SDDS.hpp:146
double compute_acceptance_ratio_shuffle(double likelihood_old_clusters, int old_ci_size, int old_cj_size)
Compute acceptance ratio for LSS shuffle move.
Definition splitmerge_LSS_SDDS.cpp:344
int accepted_split
Definition splitmerge_LSS_SDDS.hpp:145
int idx_i
Index of first randomly chosen observation.
Definition splitmerge_LSS_SDDS.hpp:84
void dumb_merge_move()
Execute a dumb merge move with direct merging.
Definition splitmerge_LSS_SDDS.cpp:222
void smart_merge_move()
Execute a smart merge move using sequential allocation.
Definition splitmerge_LSS_SDDS.cpp:196
void sequential_allocation(int iterations, bool only_probabilities=false, bool sequential=true)
Generate proposal state via sequential allocation.
Definition splitmerge_LSS_SDDS.cpp:115
int merge_moves
Definition splitmerge_LSS_SDDS.hpp:149
double get_accepted_merge() const
Get number of accepted merge moves for diagnostics.
Definition splitmerge_LSS_SDDS.hpp:399
const double rand_split_prob
Constant log probability for random split allocation (dumb split).
Definition splitmerge_LSS_SDDS.hpp:142
Eigen::Vector2d probs
Probabilities of allocating a point to clusters ci and cj.
Definition splitmerge_LSS_SDDS.hpp:130
const Eigen::VectorXi & original_allocations
Cached reference to original allocations stored in the process.
Definition splitmerge_LSS_SDDS.hpp:112
double get_accepted_shuffle() const
Get number of accepted shuffle moves for diagnostics.
Definition splitmerge_LSS_SDDS.hpp:407
Eigen::VectorXi launch_state
Launch state for sequential allocation.
Definition splitmerge_LSS_SDDS.hpp:103
void choose_clusters_shuffle()
Select clusters for shuffle move.
Definition splitmerge_LSS_SDDS.cpp:362
void choose_indeces(bool similarity=false)
Randomly select two observations for split-merge proposal.
Definition splitmerge_LSS_SDDS.cpp:22
std::mt19937 gen
Mersenne Twister random number generator for sampling operations.
Definition splitmerge_LSS_SDDS.hpp:79
bool shuffle_bool
Flag to enable shuffle moves (Mena and Martinez, 2014).
Definition splitmerge_LSS_SDDS.hpp:98
void shuffle()
Execute a shuffle move using LSS.
Definition splitmerge_LSS_SDDS.cpp:317
Eigen::VectorXi S
Indices of observations in clusters ci and cj.
Definition splitmerge_LSS_SDDS.hpp:106
double get_accepted_split() const
Get number of accepted split moves for diagnostics.
Definition splitmerge_LSS_SDDS.hpp:391
int accepted_shuffle
Definition splitmerge_LSS_SDDS.hpp:147
int idx_j
Index of second randomly chosen observation.
Definition splitmerge_LSS_SDDS.hpp:87
double compute_acceptance_ratio_merge(double likelihood_old_clusters)
Compute acceptance ratio for LSS merge move.
Definition splitmerge_LSS_SDDS.cpp:177
int cj
Cluster assignment of second observation.
Definition splitmerge_LSS_SDDS.hpp:93
double log_merge_gibbs_prob
Log probability of generating current state via sequential allocation (merge direction).
Definition splitmerge_LSS_SDDS.hpp:138
std::vector< double > row_max_distances
Definition splitmerge_LSS_SDDS.hpp:72
double log_split_gibbs_prob
Log probability of generating current state via sequential allocation (split direction).
Definition splitmerge_LSS_SDDS.hpp:134
int launch_state_size
Size of the launch state and S vectors.
Definition splitmerge_LSS_SDDS.hpp:109
void smart_split_move()
Execute a smart split move using sequential allocation.
Definition splitmerge_LSS_SDDS.cpp:248
Parameter struct for utility parameters and data structures.
Definition utils-params.hpp:17
Parameter management for useful parameters and data structures.