Struct russell_stat::DistributionFrechet
source · pub struct DistributionFrechet { /* private fields */ }
Expand description
Implements the Frechet distribution
This is a Type II Extreme Value Distribution (largest value)
See: https://en.wikipedia.org/wiki/Fr%C3%A9chet_distribution
Implementations§
Trait Implementations§
source§impl ProbabilityDistribution for DistributionFrechet
impl ProbabilityDistribution for DistributionFrechet
source§fn pdf(&self, x: f64) -> f64
fn pdf(&self, x: f64) -> f64
Evaluates the Probability Density Function (PDF)
§Examples
use russell_lab::math::NAPIER;
use russell_stat::*;
fn main() -> Result<(), StrError> {
let (location, scale, shape) = (0.0, 1.0, 2.0);
let dist = DistributionFrechet::new(location, scale, shape)?;
assert_eq!(dist.pdf(1.0), 2.0 / NAPIER);
// Mathematica: PDF[FrechetDistribution[2, 1], 1] == 2/E
Ok(())
}
source§fn cdf(&self, x: f64) -> f64
fn cdf(&self, x: f64) -> f64
Evaluates the Cumulative Distribution Function (CDF)
§Examples
use russell_lab::approx_eq;
use russell_stat::*;
fn main() -> Result<(), StrError> {
// Example from <https://reference.wolfram.com/language/ref/FrechetDistribution.html>
let (location, scale, shape) = (0.0, 6.3, 0.71);
let dist = DistributionFrechet::new(location, scale, shape)?;
let p_xx_less_than_30 = dist.cdf(30.0);
let p_xx_greater_than_30 = 1.0 - p_xx_less_than_30;
println!("P(X > 30) = {}", p_xx_greater_than_30);
approx_eq(p_xx_greater_than_30, 0.2812192884182272, 1e-15);
Ok(())
}
source§fn mean(&self) -> f64
fn mean(&self) -> f64
Returns the Mean
§Examples
use russell_lab::{approx_eq, math::SQRT_PI};
use russell_stat::*;
fn main() -> Result<(), StrError> {
let (location, scale, shape) = (0.0, 3.0, 2.0);
let dist = DistributionFrechet::new(location, scale, shape)?;
approx_eq(dist.mean(), 3.0 * SQRT_PI, 1e-15);
// Mathematica: Mean[FrechetDistribution[2, 3]]
Ok(())
}
source§fn variance(&self) -> f64
fn variance(&self) -> f64
Returns the Variance
§Examples
use russell_lab::approx_eq;
use russell_stat::*;
fn main() -> Result<(), StrError> {
let (location, scale, shape) = (0.0, 3.0, 4.0);
let dist = DistributionFrechet::new(location, scale, shape)?;
approx_eq(dist.variance(), 2.4372698060239768, 1e-14);
// Mathematica: N[Variance[FrechetDistribution[4, 3]], 17]
Ok(())
}
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
Generates a pseudo-random number belonging to this probability distribution
§Examples
use russell_stat::*;
fn main() -> Result<(), StrError> {
let (location, scale, shape) = (0.0, 3.0, 4.0);
let dist = DistributionFrechet::new(location, scale, shape)?;
let mut rng = get_rng();
println!("sample = {}", dist.sample(&mut rng));
Ok(())
}
Auto Trait Implementations§
impl Freeze for DistributionFrechet
impl RefUnwindSafe for DistributionFrechet
impl Send for DistributionFrechet
impl Sync for DistributionFrechet
impl Unpin for DistributionFrechet
impl UnwindSafe for DistributionFrechet
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