pub trait ScientificSliceRandom<T> {
// Required methods
fn scientific_shuffle<R: Rng>(&mut self, rng: &mut Random<R>);
fn scientific_choose<R: Rng>(&self, rng: &mut Random<R>) -> Option<&T>;
fn scientific_choose_multiple<R: Rng>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>;
fn scientific_sample_with_replacement<R: Rng>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>;
fn scientific_weighted_sample<R: Rng, W>(
&self,
rng: &mut Random<R>,
weights: &[W],
amount: usize,
) -> Result<Vec<&T>, String>
where W: Into<f64> + Copy;
fn scientific_reservoir_sample<R: Rng>(
&self,
rng: &mut Random<R>,
k: usize,
) -> Vec<&T>;
}Expand description
Enhanced slice random operations for scientific computing
Required Methods§
Sourcefn scientific_shuffle<R: Rng>(&mut self, rng: &mut Random<R>)
fn scientific_shuffle<R: Rng>(&mut self, rng: &mut Random<R>)
Shuffle the slice in place with enhanced performance
Sourcefn scientific_choose<R: Rng>(&self, rng: &mut Random<R>) -> Option<&T>
fn scientific_choose<R: Rng>(&self, rng: &mut Random<R>) -> Option<&T>
Choose a random element with guaranteed uniform distribution
Sourcefn scientific_choose_multiple<R: Rng>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>
fn scientific_choose_multiple<R: Rng>( &self, rng: &mut Random<R>, amount: usize, ) -> Vec<&T>
Choose multiple elements without replacement using optimal algorithms
Sourcefn scientific_sample_with_replacement<R: Rng>(
&self,
rng: &mut Random<R>,
amount: usize,
) -> Vec<&T>
fn scientific_sample_with_replacement<R: Rng>( &self, rng: &mut Random<R>, amount: usize, ) -> Vec<&T>
Sample with replacement
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.