Struct statrs::distribution::InverseGamma[][src]

pub struct InverseGamma { /* fields omitted */ }

Implements the Inverse Gamma distribution

Examples

use statrs::distribution::{InverseGamma, Continuous};
use statrs::statistics::Mean;
use statrs::prec;

let n = InverseGamma::new(1.1, 0.1).unwrap();
assert!(prec::almost_eq(n.mean(), 1.0, 1e-14));
assert_eq!(n.pdf(1.0), 0.07554920138253064);

Implementations

impl InverseGamma[src]

pub fn new(shape: f64, rate: f64) -> Result<InverseGamma>[src]

Constructs a new inverse gamma distribution with a shape (α) of shape and a rate (β) of rate

Errors

Returns an error if shape or rate are NaN. Also returns an error if shape or rate are not in (0, +inf)

Examples

use statrs::distribution::InverseGamma;

let mut result = InverseGamma::new(3.0, 1.0);
assert!(result.is_ok());

result = InverseGamma::new(0.0, 0.0);
assert!(result.is_err());

pub fn shape(&self) -> f64[src]

Returns the shape (α) of the inverse gamma distribution

Examples

use statrs::distribution::InverseGamma;

let n = InverseGamma::new(3.0, 1.0).unwrap();
assert_eq!(n.shape(), 3.0);

pub fn rate(&self) -> f64[src]

Returns the rate (β) of the inverse gamma distribution

Examples

use statrs::distribution::InverseGamma;

let n = InverseGamma::new(3.0, 1.0).unwrap();
assert_eq!(n.rate(), 1.0);

Trait Implementations

impl CheckedMean<f64> for InverseGamma[src]

fn checked_mean(&self) -> Result<f64>[src]

Returns the mean of the inverse distribution

Errors

If shape <= 1.0

Formula

β / (α - 1)

where α is the shape and β is the rate

impl CheckedSkewness<f64> for InverseGamma[src]

fn checked_skewness(&self) -> Result<f64>[src]

Returns the skewness of the inverse gamma distribution

Errors

If shape <= 3

Formula

4 * sqrt(α - 2) / (α - 3)

where α is the shape

impl CheckedVariance<f64> for InverseGamma[src]

fn checked_variance(&self) -> Result<f64>[src]

Returns the variance of the inverse gamma distribution

Errors

If shape <= 2.0

Formula

β^2 / ((α - 1)^2 * (α - 2))

where α is the shape and β is the rate

fn checked_std_dev(&self) -> Result<f64>[src]

Returns the standard deviation of the inverse gamma distribution

Errors

If shape <= 2.0

Formula

sqrt(β^2 / ((α - 1)^2 * (α - 2)))

where α is the shape and β is the rate

impl Clone for InverseGamma[src]

impl Continuous<f64, f64> for InverseGamma[src]

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

Calculates the probability density function for the inverse gamma distribution at x

Formula

(β^α / Γ(α)) * x^(-α - 1) * e^(-β / x)

where α is the shape, β is the rate, and Γ is the gamma function

fn ln_pdf(&self, x: f64) -> f64[src]

Calculates the probability density function for the inverse gamma distribution at x

Formula

ln((β^α / Γ(α)) * x^(-α - 1) * e^(-β / x))

where α is the shape, β is the rate, and Γ is the gamma function

impl Copy for InverseGamma[src]

impl Debug for InverseGamma[src]

impl Distribution<f64> for InverseGamma[src]

impl Entropy<f64> for InverseGamma[src]

fn entropy(&self) -> f64[src]

Returns the entropy of the inverse gamma distribution

Formula

α + ln(β * Γ(α)) - (1 + α) * ψ(α)

where α is the shape, β is the rate, Γ is the gamma function, and ψ is the digamma function

impl Max<f64> for InverseGamma[src]

fn max(&self) -> f64[src]

Returns the maximum value in the domain of the inverse gamma distribution representable by a double precision float

Formula

INF

impl Mean<f64> for InverseGamma[src]

fn mean(&self) -> f64[src]

Returns the mean of the inverse distribution

Panics

If shape <= 1.0

Formula

β / (α - 1)

where α is the shape and β is the rate

impl Min<f64> for InverseGamma[src]

fn min(&self) -> f64[src]

Returns the minimum value in the domain of the inverse gamma distribution representable by a double precision float

Formula

0

impl Mode<f64> for InverseGamma[src]

fn mode(&self) -> f64[src]

Returns the mode of the inverse gamma distribution

Formula

β / (α + 1)

/// where α is the shape and β is the rate

impl PartialEq<InverseGamma> for InverseGamma[src]

impl Skewness<f64> for InverseGamma[src]

fn skewness(&self) -> f64[src]

Returns the skewness of the inverse gamma distribution

Panics

If shape <= 3

Formula

4 * sqrt(α - 2) / (α - 3)

where α is the shape

impl StructuralPartialEq for InverseGamma[src]

impl Univariate<f64, f64> for InverseGamma[src]

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

Calculates the cumulative distribution function for the inverse gamma distribution at x

Formula

Γ(α, β / x) / Γ(α)

where the numerator is the upper incomplete gamma function, the denominator is the gamma function, α is the shape, and β is the rate

impl Variance<f64> for InverseGamma[src]

fn variance(&self) -> f64[src]

Returns the variance of the inverse gamma distribution

Panics

If shape <= 2.0

Formula

β^2 / ((α - 1)^2 * (α - 2))

where α is the shape and β is the rate

fn std_dev(&self) -> f64[src]

Returns the standard deviation of the inverse gamma distribution

Panics

If shape <= 2.0

Formula

sqrt(β^2 / ((α - 1)^2 * (α - 2)))

where α is the shape and β is the rate

Auto Trait Implementations

impl RefUnwindSafe for InverseGamma

impl Send for InverseGamma

impl Sync for InverseGamma

impl Unpin for InverseGamma

impl UnwindSafe for InverseGamma

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]