pub struct Triangular<N> { /* 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§
Source§impl<N: Float> Triangular<N>where
Standard: Distribution<N>,
impl<N: Float> Triangular<N>where
Standard: Distribution<N>,
Sourcepub fn new(min: N, max: N, mode: N) -> Result<Triangular<N>, TriangularError>
pub fn new(min: N, max: N, mode: N) -> Result<Triangular<N>, TriangularError>
Set up the Triangular distribution with defined min
, max
and mode
.
Trait Implementations§
Source§impl<N: Clone> Clone for Triangular<N>
impl<N: Clone> Clone for Triangular<N>
Source§fn clone(&self) -> Triangular<N>
fn clone(&self) -> Triangular<N>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<N: Debug> Debug for Triangular<N>
impl<N: Debug> Debug for Triangular<N>
Source§impl<N: Float> Distribution<N> for Triangular<N>where
Standard: Distribution<N>,
impl<N: Float> Distribution<N> for Triangular<N>where
Standard: Distribution<N>,
impl<N: Copy> Copy for Triangular<N>
Auto Trait Implementations§
impl<N> Freeze for Triangular<N>where
N: Freeze,
impl<N> RefUnwindSafe for Triangular<N>where
N: RefUnwindSafe,
impl<N> Send for Triangular<N>where
N: Send,
impl<N> Sync for Triangular<N>where
N: Sync,
impl<N> Unpin for Triangular<N>where
N: Unpin,
impl<N> UnwindSafe for Triangular<N>where
N: UnwindSafe,
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