usecrate::algebra::abstr::Real;usestd::iter;pubtraitDistribution<T>whereT: Real,{fnrandom(&self)-> T;fnrandom_sequence(&self,size: u32)-> Vec<T>{letmutv: Vec<T>=Vec::new();v.extend(iter::repeat_with(&||self.random()).take(sizeasusize));v}}/// Continuous distribution
pubtraitContinuous<T>whereT: Real,{/// Probability density function
///
/// # Arguments
///
/// *`x`:
fnpdf(&self,x: T)-> T;/// Cumulative distribution function
///
/// # Arguments
///
/// *`x`:
fncdf(&self,x: T)-> T;/// Quantile function, inverse cdf
fnquantile(&self,p: T)-> T;/// Mean
fnmean(&self)-> T;/// Variance
fnvariance(&self)-> T;/// Skewness is a measure of the asymmetry of the probability distribution
/// of a real-valued random variable about its mean
fnskewness(&self)-> T;/// Median is the value separating the higher half from the lower half of a
/// probability distribution.
fnmedian(&self)-> T;///
fnentropy(&self)-> T;}/// Discrete distribution
pubtraitDiscrete<T,A,B>{/// Probability mass function
///
/// # Arguments
///
/// *`x`:
fnpmf(&self,x: A)-> T;///Cumulative distribution function
///
/// # Arguments
///
/// * `x`:
fncdf(&self,x: B)-> T;/// Mean
fnmean(&self)-> T;/// Variance
fnvariance(&self)-> T;}
Discrete trait
All discrete distribution implements the Discrete trait
usecrate::algebra::abstr::Real;usestd::iter;pubtraitDistribution<T>whereT: Real,{fnrandom(&self)-> T;fnrandom_sequence(&self,size: u32)-> Vec<T>{letmutv: Vec<T>=Vec::new();v.extend(iter::repeat_with(&||self.random()).take(sizeasusize));v}}/// Continuous distribution
pubtraitContinuous<T>whereT: Real,{/// Probability density function
///
/// # Arguments
///
/// *`x`:
fnpdf(&self,x: T)-> T;/// Cumulative distribution function
///
/// # Arguments
///
/// *`x`:
fncdf(&self,x: T)-> T;/// Quantile function, inverse cdf
fnquantile(&self,p: T)-> T;/// Mean
fnmean(&self)-> T;/// Variance
fnvariance(&self)-> T;/// Skewness is a measure of the asymmetry of the probability distribution
/// of a real-valued random variable about its mean
fnskewness(&self)-> T;/// Median is the value separating the higher half from the lower half of a
/// probability distribution.
fnmedian(&self)-> T;///
fnentropy(&self)-> T;}/// Discrete distribution
pubtraitDiscrete<T,A,B>{/// Probability mass function
///
/// # Arguments
///
/// *`x`:
fnpmf(&self,x: A)-> T;///Cumulative distribution function
///
/// # Arguments
///
/// * `x`:
fncdf(&self,x: B)-> T;/// Mean
fnmean(&self)-> T;/// Variance
fnvariance(&self)-> T;}