Learn R Programming

extraDistr (version 1.8.1)

InvGamma: Inverse-gamma distribution

Description

Density, distribution function and random generation for the inverse-gamma distribution.

Usage

dinvgamma(x, alpha, beta = 1, log = FALSE)
pinvgamma(q, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE)
qinvgamma(p, alpha, beta = 1, lower.tail = TRUE, log.p = FALSE)
rinvgamma(n, alpha, beta = 1)

Arguments

x, q
vector of quantiles.
alpha, beta
positive valued shape and scale parameters.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
p
vector of probabilities.
n
number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability mass function $$ f(x) = \frac{x^{-\alpha-1} \exp(-\frac{1}{\beta x})}{\Gamma(\alpha) \beta^\alpha} $$

Cumulative distribution function $$ F(x) = \frac{\gamma(\alpha, \frac{1}{\beta x})}{\Gamma(\alpha)} $$

References

Witkovsky, V. (2001). Computing the distribution of a linear combination of inverted gamma variables. Kybernetika 37(1), 79-90.

Leemis, L.M. and McQueston, L.T. (2008). Univariate Distribution Relationships. American Statistician 62(1): 45-53.

See Also

GammaDist

Examples

Run this code

x <- rinvgamma(1e5, 20, 3)
xx <- seq(0, 1, by = 0.001)
hist(x, 100, freq = FALSE)
lines(xx, dinvgamma(xx, 20, 3), col = "red")
hist(pinvgamma(x, 20, 3))
plot(ecdf(x))
lines(xx, pinvgamma(xx, 20, 3), col = "red", lwd = 2) 

Run the code above in your browser using DataLab