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, InverseGammaError>
pub fn new(shape: f64, rate: f64) -> Result<InverseGamma, InverseGammaError>
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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 sf(&self, x: f64) -> f64
fn sf(&self, x: f64) -> f64
Calculates the survival function for the inverse gamma
distribution at x
§Formula
Γ(α, β / x) / Γ(α)
where the numerator is the lower 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
cdf
to obtain an approximation
of F^-1(p) := inf { x | F(x) >= p }
. Needless to say, performance may
may be lacking.Source§impl Debug for InverseGamma
impl Debug for InverseGamma
Source§impl Display for InverseGamma
impl Display for InverseGamma
Source§impl Distribution<f64> for InverseGamma
impl Distribution<f64> for InverseGamma
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 for InverseGamma
impl PartialEq for InverseGamma
impl Copy for InverseGamma
impl StructuralPartialEq for InverseGamma
Auto Trait Implementations§
impl Freeze for InverseGamma
impl RefUnwindSafe for InverseGamma
impl Send for InverseGamma
impl Sync for InverseGamma
impl Unpin for InverseGamma
impl UnwindSafe for InverseGamma
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.