pub struct Triangular { /* private fields */ }Expand description
Triangular distribution with parameters [min, mode, max].
§Mathematical Definition
- PDF: piecewise linear, peaking at mode
- CDF: piecewise quadratic
- Mean: (min + mode + max) / 3
- Variance: (a² + b² + c² − ab − ac − bc) / 18
Reference: Johnson, Kotz & Balakrishnan (1995), Continuous Univariate Distributions, Vol. 2, Chapter 26.
Implementations§
Source§impl Triangular
impl Triangular
Sourcepub fn new(min: f64, mode: f64, max: f64) -> Result<Self, DistributionError>
pub fn new(min: f64, mode: f64, max: f64) -> Result<Self, DistributionError>
Creates a new triangular distribution.
§Errors
Returns Err if min >= max or mode is outside [min, max].
pub fn min(&self) -> f64
pub fn mode(&self) -> f64
pub fn max(&self) -> f64
Sourcepub fn pdf(&self, x: f64) -> f64
pub fn pdf(&self, x: f64) -> f64
PDF of the triangular distribution.
f(x) = 2(x−a) / ((c−a)(b−a)) for a ≤ x ≤ b
= 2(c−x) / ((c−a)(c−b)) for b < x ≤ c
= 0 otherwiseTrait Implementations§
Source§impl Clone for Triangular
impl Clone for Triangular
Source§fn clone(&self) -> Triangular
fn clone(&self) -> Triangular
Returns a duplicate 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 Debug for Triangular
impl Debug for Triangular
Source§impl PartialEq for Triangular
impl PartialEq for Triangular
impl StructuralPartialEq for Triangular
Auto Trait Implementations§
impl Freeze for Triangular
impl RefUnwindSafe for Triangular
impl Send for Triangular
impl Sync for Triangular
impl Unpin for Triangular
impl UnsafeUnpin for Triangular
impl UnwindSafe for Triangular
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