pub struct WeightedReservoirSampler { /* private fields */ }Expand description
Weighted reservoir sampling for stratified sampling
Implementations§
Source§impl WeightedReservoirSampler
impl WeightedReservoirSampler
pub fn new(capacity: usize, weights: HashMap<String, f64>) -> Self
Sourcepub fn process_weighted_record(
&mut self,
record_index: usize,
category: &str,
) -> bool
pub fn process_weighted_record( &mut self, record_index: usize, category: &str, ) -> bool
Process a record with associated weight category
pub fn get_sample_indices(&self) -> &[usize]
pub fn sampling_ratio(&self) -> f64
Trait Implementations§
Source§impl Clone for WeightedReservoirSampler
impl Clone for WeightedReservoirSampler
Source§fn clone(&self) -> WeightedReservoirSampler
fn clone(&self) -> WeightedReservoirSampler
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WeightedReservoirSampler
impl RefUnwindSafe for WeightedReservoirSampler
impl Send for WeightedReservoirSampler
impl Sync for WeightedReservoirSampler
impl Unpin for WeightedReservoirSampler
impl UnsafeUnpin for WeightedReservoirSampler
impl UnwindSafe for WeightedReservoirSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more