Struct statrs::distribution::InverseGamma [−][src]
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]
impl CheckedSkewness<f64> for InverseGamma
[src]
fn checked_skewness(&self) -> Result<f64>
[src]
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]
impl Clone for InverseGamma
[src]
fn clone(&self) -> InverseGamma
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
pub fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]
R: Rng,
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]
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]
fn eq(&self, other: &InverseGamma) -> bool
[src]
fn ne(&self, other: &InverseGamma) -> bool
[src]
impl Skewness<f64> for InverseGamma
[src]
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]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,