Struct russell_stat::DistributionGumbel

source ·
pub struct DistributionGumbel { /* private fields */ }
Expand description

Implements the Gumbel distribution

This is a Type I Extreme Value Distribution (largest value)

See: https://en.wikipedia.org/wiki/Gumbel_distribution

Gumbel

Implementations§

source§

impl DistributionGumbel

source

pub fn new(location: f64, scale: f64) -> Result<Self, StrError>

Allocates a new instance

§Input
  • location – characteristic largest value
  • scale – measure of dispersion of the largest value
source

pub fn new_from_mu_sig(mu: f64, sig: f64) -> Result<Self, StrError>

Creates a new Gumbel distribution given mean and standard deviation parameters

§Input
  • mu – mean μ
  • sig – standard deviation σ

Trait Implementations§

source§

impl ProbabilityDistribution for DistributionGumbel

source§

fn pdf(&self, x: f64) -> f64

Evaluates the Probability Density Function (PDF)

use russell_lab::approx_eq;
use russell_stat::*;

fn main() -> Result<(), StrError> {
    let (location, scale) = (2.0, 3.0);
    let dist = DistributionGumbel::new(location, scale)?;
    approx_eq(dist.pdf(1.0), 0.11522236828583457, 1e-15);
    // R:
    //   library(evd)
    //   format(dgumbel(1.0, 2.0, 3.0), digits=17)
    // Mathematica:
    //   N[PDF[GumbelDistribution[-2, 3], -1], 17]
    Ok(())
}
source§

fn cdf(&self, x: f64) -> f64

Evaluates the Cumulative Distribution Function (CDF)

use russell_lab::approx_eq;
use russell_stat::*;

fn main() -> Result<(), StrError> {
    let (location, scale) = (2.0, 3.0);
    let dist = DistributionGumbel::new(location, scale)?;
    approx_eq(dist.cdf(1.0), 0.24768130366579455, 1e-15);
    // R:
    //   library(evd)
    //   format(pgumbel(1.0, 2.0, 3.0), digits=17)
    // Mathematica:
    //   N[1 - CDF[GumbelDistribution[-2, 3], -1], 17]
    Ok(())
}
source§

fn mean(&self) -> f64

Returns the Mean

use russell_lab::{approx_eq, math::EULER};
use russell_stat::*;

fn main() -> Result<(), StrError> {
    let (location, scale) = (2.0, 3.0);
    let dist = DistributionGumbel::new(location, scale)?;
    approx_eq(dist.mean(), location + EULER * scale, 1e-15);
    // Mathematica: -Mean[GumbelDistribution[-location, scale]]
    Ok(())
}
source§

fn variance(&self) -> f64

Returns the Variance

§Examples
use russell_lab::approx_eq;
use russell_stat::*;

fn main() -> Result<(), StrError> {
    let (location, scale) = (2.0, 3.0);
    let dist = DistributionGumbel::new(location, scale)?;
    approx_eq(dist.variance(), 14.804406601634038, 1e-14);
    // Mathematica: N[Variance[GumbelDistribution[-2, 3]], 17]
    Ok(())
}
source§

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) = (2.0, 3.0);
    let dist = DistributionGumbel::new(location, scale)?;
    let mut rng = get_rng();
    println!("sample = {}", dist.sample(&mut rng));
    Ok(())
}

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V