pub struct Triangular<F>{ /* private fields */ }
Expand description
The triangular distribution Triangular(min, max, mode)
.
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.
§Plot
The following plot shows the triangular distribution with various values of
min
, max
, and mode
.
§Example
use rand_distr::{Triangular, Distribution};
let d = Triangular::new(0., 5., 2.5).unwrap();
let v = d.sample(&mut rand::rng());
println!("{} is from a triangular distribution", v);
Implementations§
Source§impl<F> Triangular<F>
impl<F> Triangular<F>
Sourcepub fn new(min: F, max: F, mode: F) -> Result<Triangular<F>, TriangularError>
pub fn new(min: F, max: F, mode: F) -> Result<Triangular<F>, TriangularError>
Set up the Triangular distribution with defined min
, max
and mode
.
Trait Implementations§
Source§impl<F> Clone for Triangular<F>
impl<F> Clone for Triangular<F>
Source§fn clone(&self) -> Triangular<F>
fn clone(&self) -> Triangular<F>
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<F> Debug for Triangular<F>
impl<F> Debug for Triangular<F>
Source§impl<'de, F> Deserialize<'de> for Triangular<F>
impl<'de, F> Deserialize<'de> for Triangular<F>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<F> Distribution<F> for Triangular<F>
impl<F> Distribution<F> for Triangular<F>
Source§impl<F> PartialEq for Triangular<F>
impl<F> PartialEq for Triangular<F>
Source§impl<F> Serialize for Triangular<F>
impl<F> Serialize for Triangular<F>
impl<F> Copy for Triangular<F>
impl<F> StructuralPartialEq for Triangular<F>
Auto Trait Implementations§
impl<F> Freeze for Triangular<F>where
F: Freeze,
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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)