let add clusters test distribution nb_samples_distribution =
let rec merge_if_match cluster =
if test cluster.distribution cluster.nb_samples distribution nb_samples_distribution
then (
(* merge cluster distribution nb_samples_distribution; (\* !! *\) *)
raise (Found cluster.id)) in
try Cluster_collection.iter merge_if_match clusters.clusters;
(* no Found raised, we create a new cluster containing only [distribution] *)
let id = clusters.id_generator () in
Cluster_collection.push
{id = id;
distribution = Array.copy distribution;
nb_samples = nb_samples_distribution
(* ;nb_distributions = 1 (\* !! *\) *)
}
clusters.clusters;
id
with Found id -> id