| invgamma | R Documentation |
These functions provide the density function, distribution function, quantile function, and random number generation for the Inverse-Gamma (IG) Distribution
dinvgamma(x, shape = 2.5, scale = 1, log = FALSE)
pinvgamma(q, shape = 2.5, scale = 1, lower.tail = TRUE, log.p = FALSE)
qinvgamma(p, shape = 2.5, scale = 1, lower.tail = TRUE, log.p = FALSE)
rinvgamma(n, shape = 2.5, scale = 1)
x |
numeric value or a vector of values. |
shape |
numeric value or vector of shape values for the distribution (the values have to be greater than 0). |
scale |
single value or vector of values for the scale parameter of the distribution (the values have to be greater than 0). |
log |
logical; if TRUE, probabilities p are given as log(p). |
q |
quantile or a vector of quantiles. |
lower.tail |
logical; if TRUE, probabilities p are |
log.p |
logical; if TRUE, probabilities p are given as log(p). |
p |
probability or a vector of probabilities. |
n |
the number of random numbers to generate. |
dinvgamma computes the density (PDF) of the Inverse-Gamma
Distribution.
pinvgamma computes the CDF of the Inverse-Gamma Distribution.
qinvgamma computes the quantile function of the Inverse-Gamma
Distribution.
rinvgamma generates random numbers from the Inverse-Gamma
Distribution.
The compound Probability Mass Function (PMF) for the Inverse-Gamma distribution:
f(x | \alpha, \beta) =
\frac{\beta^\alpha}{\Gamma(\alpha)}
\left(\frac{1}{x}\right)^{\alpha+1} e^{-\frac{\beta}{x}}
Where \alpha is the shape parameter and \beta is a scale
parameter with the restrictions that \alpha > 0 and \eta > 0, and
x > 0.
The CDF of the Inverse-Gamma distribution is:
F(x | \alpha, \beta) =
\frac{\alpha. \Gamma \left(\frac{\beta}{x}\right)}{\Gamma(\alpha)} =
Q\left(\alpha, \frac{\beta}{x} \right)
Where the numerator is the incomplete gamma function and Q(\cdot) is
the regularized gamma function.
The mean of the distribution is (provided \alpha>1):
\mu=\frac{\beta}{\alpha-1}
The variance of the distribution is (for \alpha>2):
\sigma^2=\frac{\beta^2}{(\alpha-1)^2(\alpha-2)}
dinvgamma gives the density, pinvgamma gives the distribution function, qinvgamma gives the quantile function, and rinvgamma generates random deviates.
The length of the result is determined by n for rinvgamma, and is the maximum of the lengths of the numerical arguments for the other functions.
dinvgamma(1, shape = 3, scale = 2)
pinvgamma(c(0.1, 0.5, 1, 3, 5, 10, 30), shape = 3, scale = 2)
qinvgamma(c(0.1, 0.3, 0.5, 0.9, 0.95), shape = 3, scale = 2)
rinvgamma(30, shape = 3, scale = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.