Trait statrs::statistics::Distribution
source · pub trait Distribution<T: Float>: Distribution<T> {
// Provided methods
fn mean(&self) -> Option<T> { ... }
fn variance(&self) -> Option<T> { ... }
fn std_dev(&self) -> Option<T> { ... }
fn entropy(&self) -> Option<T> { ... }
fn skewness(&self) -> Option<T> { ... }
}
Provided Methods§
sourcefn mean(&self) -> Option<T>
fn mean(&self) -> Option<T>
Returns the mean, if it exists. The default implementation returns an estimation based on random samples. This is a crude estimate for when no further information is known about the distribution. More accurate statements about the mean can and should be given by overriding the default implementation.
Examples
use statrs::statistics::Distribution;
use statrs::distribution::Uniform;
let n = Uniform::new(0.0, 1.0).unwrap();
assert_eq!(0.5, n.mean().unwrap());
sourcefn variance(&self) -> Option<T>
fn variance(&self) -> Option<T>
Returns the variance, if it exists. The default implementation returns an estimation based on random samples. This is a crude estimate for when no further information is known about the distribution. More accurate statements about the variance can and should be given by overriding the default implementation.
Examples
use statrs::statistics::Distribution;
use statrs::distribution::Uniform;
let n = Uniform::new(0.0, 1.0).unwrap();
assert_eq!(1.0 / 12.0, n.variance().unwrap());
sourcefn std_dev(&self) -> Option<T>
fn std_dev(&self) -> Option<T>
Returns the standard deviation, if it exists.
Examples
use statrs::statistics::Distribution;
use statrs::distribution::Uniform;
let n = Uniform::new(0.0, 1.0).unwrap();
assert_eq!((1f64 / 12f64).sqrt(), n.std_dev().unwrap());