sampling-tree
A simple sampling tree implementation for sampling discrete distributions with sparse dynamic updates.
This allows us to sample efficiently from a distribution given the relative importance of each datapoint.
Construction time is O(n), updating is O(log(n)), and sampling is O(log(n)). The memory footprint is no more than twice the size of n*std::mem::size_of::<T>()
where T
is weight datatype.
Basic usage:
let mut rng = thread_rng;
let n = 100;
let range = 10000u32;
let data = .map;
let mut sampling_tree: = from_iterable.unwrap;
println!;
let sample_idx = sampling_tree.sample.unwrap;
println!;
sampling_tree.update.unwrap;
println!;
Supports most numeric types for the type of each datapoint's weight.