Struct rand_distr::Triangular
source · [−]pub struct Triangular<F> where
F: Float,
Standard: Distribution<F>, { /* private fields */ }
Expand description
The triangular distribution.
A continuous probability distribution parameterised by a range, and a mode (most likely value) within that range.
The probability density function is triangular. For a similar distribution
with a smooth PDF, see the Pert
distribution.
Example
use rand_distr::{Triangular, Distribution};
let d = Triangular::new(0., 5., 2.5).unwrap();
let v = d.sample(&mut rand::thread_rng());
println!("{} is from a triangular distribution", v);
Implementations
Set up the Triangular distribution with defined min
, max
and mode
.
Trait Implementations
Generate a random value of T
, using rng
as the source of randomness.
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
Auto Trait Implementations
impl<F> RefUnwindSafe for Triangular<F> where
F: RefUnwindSafe,
impl<F> Send for Triangular<F> where
F: Send,
impl<F> Sync for Triangular<F> where
F: Sync,
impl<F> Unpin for Triangular<F> where
F: Unpin,
impl<F> UnwindSafe for Triangular<F> where
F: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more