Struct statrs::distribution::InverseGamma
source · [−]pub struct InverseGamma { /* private fields */ }
Expand description
Implements the Inverse Gamma distribution
Examples
use statrs::distribution::{InverseGamma, Continuous};
use statrs::statistics::Distribution;
use statrs::prec;
let n = InverseGamma::new(1.1, 0.1).unwrap();
assert!(prec::almost_eq(n.mean().unwrap(), 1.0, 1e-14));
assert_eq!(n.pdf(1.0), 0.07554920138253064);
Implementations
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());
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);
Trait Implementations
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
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
Due to issues with rounding and floating-point accuracy the default
implementation may be ill-behaved.
Specialized inverse cdfs should be used whenever possible.
Performs a binary search on the domain of cdf
to obtain an approximation
of F^-1(p) := inf { x | F(x) >= p }
. Needless to say, performance may
may be lacking. Read more
Generate a random value of T
, using rng
as the source of randomness.
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Mutably borrows from an owned value. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
Checks if self
is actually part of its subset T
(and can be converted to it).
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
The inclusion map: converts self
to the equivalent element of its superset.