Learn R Programming

distributional (version 0.5.0)

dist_gamma: The Gamma distribution

Description

[Stable]

Several important distributions are special cases of the Gamma distribution. When the shape parameter is 1, the Gamma is an exponential distribution with parameter \(1/\beta\). When the \(shape = n/2\) and \(rate = 1/2\), the Gamma is a equivalent to a chi squared distribution with n degrees of freedom. Moreover, if we have \(X_1\) is \(Gamma(\alpha_1, \beta)\) and \(X_2\) is \(Gamma(\alpha_2, \beta)\), a function of these two variables of the form \(\frac{X_1}{X_1 + X_2}\) \(Beta(\alpha_1, \alpha_2)\). This last property frequently appears in another distributions, and it has extensively been used in multivariate methods. More about the Gamma distribution will be added soon.

Usage

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

Arguments

shape, scale

shape and scale parameters. Must be positive, scale strictly.

rate

an alternative way to specify the scale.

Details

We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.

In the following, let \(X\) be a Gamma random variable with parameters shape = \(\alpha\) and rate = \(\beta\).

Support: \(x \in (0, \infty)\)

Mean: \(\frac{\alpha}{\beta}\)

Variance: \(\frac{\alpha}{\beta^2}\)

Probability density function (p.m.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}} $$

Moment generating function (m.g.f):

$$ E(e^{tX}) = \Big(\frac{\beta}{ \beta - t}\Big)^{\alpha}, \thinspace t < \beta $$

See Also

Examples

Run this code
dist <- dist_gamma(shape = c(1,2,3,5,9,7.5,0.5), rate = c(0.5,0.5,0.5,1,2,1,1))

dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)

generate(dist, 10)

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

cdf(dist, 4)

quantile(dist, 0.7)

Run the code above in your browser using DataLab