Struct statrs::distribution::Triangular [−][src]
pub struct Triangular { /* fields omitted */ }
Implements the Triangular distribution
Examples
use statrs::distribution::{Triangular, Continuous}; use statrs::statistics::Mean; let n = Triangular::new(0.0, 5.0, 2.5).unwrap(); assert_eq!(n.mean(), 7.5 / 3.0); assert_eq!(n.pdf(2.5), 5.0 / 12.5);
Implementations
impl Triangular
[src]
impl Triangular
[src]pub fn new(min: f64, max: f64, mode: f64) -> Result<Triangular>
[src]
Constructs a new triangular distribution with a minimum of min
,
maximum of max
, and a mode of mode
.
Errors
Returns an error if min
, max
, or mode
are NaN
or ±INF
.
Returns an error if max < mode
, mode < min
, or max == min
.
Examples
use statrs::distribution::Triangular; let mut result = Triangular::new(0.0, 5.0, 2.5); assert!(result.is_ok()); result = Triangular::new(2.5, 1.5, 0.0); assert!(result.is_err());
Trait Implementations
impl Clone for Triangular
[src]
impl Clone for Triangular
[src]fn clone(&self) -> Triangular
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Continuous<f64, f64> for Triangular
[src]
impl Continuous<f64, f64> for Triangular
[src]fn pdf(&self, x: f64) -> f64
[src]
Calculates the probability density function for the triangular
distribution
at x
Formula
ⓘ
if x < min { 0 } else if min <= x <= mode { 2 * (x - min) / ((max - min) * (mode - min)) } else if mode < x <= max { 2 * (max - x) / ((max - min) * (max - mode)) } else { 0 }
fn ln_pdf(&self, x: f64) -> f64
[src]
Calculates the log probability density function for the triangular
distribution
at x
Formula
ⓘ
ln( if x < min { 0 } else if min <= x <= mode { 2 * (x - min) / ((max - min) * (mode - min)) } else if mode < x <= max { 2 * (max - x) / ((max - min) * (max - mode)) } else { 0 } )
impl Distribution<f64> for Triangular
[src]
impl Distribution<f64> for Triangular
[src]impl Entropy<f64> for Triangular
[src]
impl Entropy<f64> for Triangular
[src]impl Max<f64> for Triangular
[src]
impl Max<f64> for Triangular
[src]impl Mean<f64> for Triangular
[src]
impl Mean<f64> for Triangular
[src]impl Median<f64> for Triangular
[src]
impl Median<f64> for Triangular
[src]impl Min<f64> for Triangular
[src]
impl Min<f64> for Triangular
[src]impl Mode<f64> for Triangular
[src]
impl Mode<f64> for Triangular
[src]impl PartialEq<Triangular> for Triangular
[src]
impl PartialEq<Triangular> for Triangular
[src]fn eq(&self, other: &Triangular) -> bool
[src]
fn ne(&self, other: &Triangular) -> bool
[src]
impl Skewness<f64> for Triangular
[src]
impl Skewness<f64> for Triangular
[src]impl Univariate<f64, f64> for Triangular
[src]
impl Univariate<f64, f64> for Triangular
[src]impl Variance<f64> for Triangular
[src]
impl Variance<f64> for Triangular
[src]fn variance(&self) -> f64
[src]
Returns the variance of the triangular distribution
Formula
ⓘ
(min^2 + max^2 + mode^2 - min * max - min * mode - max * mode) / 18
fn std_dev(&self) -> f64
[src]
Returns the standard deviation of the triangular distribution
Formula
ⓘ
sqrt((min^2 + max^2 + mode^2 - min * max - min * mode - max * mode) / 18)