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§
source§impl InverseGamma
impl InverseGamma
sourcepub fn new(shape: f64, rate: f64) -> Result<InverseGamma>
pub fn new(shape: f64, rate: f64) -> Result<InverseGamma>
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());
Trait Implementations§
source§impl Clone for InverseGamma
impl Clone for InverseGamma
source§fn clone(&self) -> InverseGamma
fn clone(&self) -> InverseGamma
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Continuous<f64, f64> for InverseGamma
impl Continuous<f64, f64> for InverseGamma
source§impl ContinuousCDF<f64, f64> for InverseGamma
impl ContinuousCDF<f64, f64> for InverseGamma
source§fn cdf(&self, x: f64) -> f64
fn cdf(&self, x: f64) -> f64
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
source§fn inverse_cdf(&self, p: T) -> K
fn inverse_cdf(&self, p: T) -> K
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 moresource§impl Debug for InverseGamma
impl Debug for InverseGamma
source§impl Distribution<f64> for InverseGamma
impl Distribution<f64> for InverseGamma
source§fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
Generate a random value of
T
, using rng
as the source of randomness.source§impl Distribution<f64> for InverseGamma
impl Distribution<f64> for InverseGamma
source§fn entropy(&self) -> Option<f64>
fn entropy(&self) -> Option<f64>
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
source§impl Max<f64> for InverseGamma
impl Max<f64> for InverseGamma
source§impl Min<f64> for InverseGamma
impl Min<f64> for InverseGamma
source§impl PartialEq<InverseGamma> for InverseGamma
impl PartialEq<InverseGamma> for InverseGamma
source§fn eq(&self, other: &InverseGamma) -> bool
fn eq(&self, other: &InverseGamma) -> bool
impl Copy for InverseGamma
impl StructuralPartialEq for InverseGamma
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§
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.