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 duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
 
const 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<Triangular<F>, <__D as Deserializer<'de>>::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(
    __deserializer: __D,
) -> Result<Triangular<F>, <__D as Deserializer<'de>>::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>
Source§fn serialize<__S>(
    &self,
    __serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
    __S: Serializer,
 
fn serialize<__S>(
    &self,
    __serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
    __S: Serializer,
Serialize this value into the given Serde serializer. Read more
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> CallInPlace<T> for Twhere
    T: CallInto<T>,
 
impl<T> CallInPlace<T> for Twhere
    T: CallInto<T>,
Source§fn call_inplace<F>(&mut self, f: F) -> <T as CallInto<T>>::Output
 
fn call_inplace<F>(&mut self, f: F) -> <T as CallInto<T>>::Output
The 
call_on_mut method allows an object to be passed onto a function that takes a mutable reference
to the object. This is useful for cases where you want to perform an operation on
an object and mutate it in the process.Source§impl<T> CallInto<T> for T
 
impl<T> CallInto<T> for T
Source§impl<T> CallOn<T> for Twhere
    T: CallInto<T>,
 
impl<T> CallOn<T> for Twhere
    T: CallInto<T>,
Source§fn call_on<F>(&self, f: F) -> <T as CallInto<T>>::Output
 
fn call_on<F>(&self, f: F) -> <T as CallInto<T>>::Output
The 
call_on method allows an object to be passed onto a function that takes a reference
to the object. This is useful for cases where you want to perform an operation on
an object without needing to extract it from a container or context.