41 const int K = initial_allocations.maxCoeff() + 1;
45 for (
int i = 0; i < initial_allocations.size(); ++i) {
46 int cluster = initial_allocations(i);
54 stats.
sumsq += value * value;
65 void set_allocation(
int index,
int cluster,
int old_cluster)
override;
86 void recompute(
const int K,
const Eigen::VectorXi &allocations)
override;
Abstract base class for managing cluster information and caches.
void move_cluster_info(int from_cluster, int to_cluster) override
Moves cluster information from one cluster to another.
Definition continuos_cache.hpp:93
std::vector< ClusterStats > cluster_stats
Definition continuos_cache.hpp:32
ContinuosCache(Eigen::VectorXi &initial_allocations, const Eigen::VectorXd &continuos_covariates)
Definition continuos_cache.hpp:37
void recompute(const int K, const Eigen::VectorXi &allocations) override
Recomputes all cluster information from current allocations.
Definition continuos_cache.cpp:34
const ClusterStats & get_cluster_stats_ref(int cluster) const
Get cluster statistics reference for a specific cluster.
Definition continuos_cache.hpp:79
void set_allocation(int index, int cluster, int old_cluster) override
Assigns a point to a cluster.
Definition continuos_cache.cpp:8
void remove_info(int cluster) override
Removes information related to a specific cluster.
Definition continuos_cache.cpp:56
const Eigen::VectorXd continuos_covariates
Definition continuos_cache.hpp:35
ClusterStats get_cluster_stats(int cluster) const
Get cluster statistics for a specific cluster.
Definition continuos_cache.hpp:72
Structure to hold statistics for each cluster.
Definition continuos_cache.hpp:25
double sum
Definition continuos_cache.hpp:27
double sumsq
Definition continuos_cache.hpp:28
int n
Definition continuos_cache.hpp:26