Skip to main content

Sample

Trait Sample 

Source
pub trait Sample {
    // Required method
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64;

    // Provided method
    fn sample_n(&self, n: usize, seed: u64) -> Vec<f64> { ... }
}
Expand description

A distribution that can draw random variates.

§Examples

use u_numflow::distributions::{Sample, Weibull};

let w = Weibull::new(2.0, 100.0).unwrap();
let a = w.sample_n(1000, 42);
assert_eq!(a, w.sample_n(1000, 42)); // same seed, same draws
assert!(a.iter().all(|&t| t > 0.0 && t.is_finite()));

Required Methods§

Source

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64

One variate, drawn with rng.

Provided Methods§

Source

fn sample_n(&self, n: usize, seed: u64) -> Vec<f64>

n variates from a generator seeded with seed (create_rng): the same (n, seed) always gives the same values.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§