dist_inverse_gamma: The Inverse Gamma distribution

View source: R/dist_inverse_gamma.R

dist_inverse_gammaR Documentation

The Inverse Gamma distribution

Description

[Stable]

The Inverse Gamma distribution is commonly used as a prior distribution in Bayesian statistics, particularly for variance parameters.

Usage

dist_inverse_gamma(shape, rate = 1/scale, scale)

Arguments

shape, scale

parameters. Must be strictly positive.

rate

an alternative way to specify the scale.

Details

We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_inverse_gamma.html

In the following, let X be an Inverse Gamma random variable with shape parameter shape = \alpha and rate parameter rate = \beta (equivalently, scale = 1/\beta).

Support: x \in (0, \infty)

Mean: \frac{\beta}{\alpha - 1} for \alpha > 1, otherwise undefined

Variance: \frac{\beta^2}{(\alpha - 1)^2 (\alpha - 2)} for \alpha > 2, otherwise undefined

Probability density function (p.d.f):

f(x) = \frac{\beta^\alpha}{\Gamma(\alpha)} x^{-\alpha - 1} e^{-\beta/x}

Cumulative distribution function (c.d.f):

F(x) = \frac{\Gamma(\alpha, \beta/x)}{\Gamma(\alpha)} = Q(\alpha, \beta/x)

where \Gamma(\alpha, z) is the upper incomplete gamma function and Q is the regularized incomplete gamma function.

Moment generating function (m.g.f):

M_X(t) = \frac{2 (-\beta t)^{\alpha/2}}{\Gamma(\alpha)} K_\alpha\left(\sqrt{-4\beta t}\right)

for t < 0, where K_\alpha is the modified Bessel function of the second kind. The MGF does not exist for t \ge 0.

See Also

actuar::InverseGamma

Examples

dist <- dist_inverse_gamma(shape = c(1,2,3,3), rate = c(1,1,1,2))
dist


mean(dist)
variance(dist)
support(dist)
generate(dist, 10)

density(dist, 2)
density(dist, 2, log = TRUE)

cdf(dist, 4)

quantile(dist, 0.7)


distributional documentation built on June 27, 2026, 5:06 p.m.