Generalized gamma distribution

The generalized gamma distribution is a continuous probability distribution with two shape parameters (and a scale parameter). It is a generalization of the gamma distribution which has one shape parameter (and a scale parameter). Since many distributions commonly used for parametric models in survival analysis (such as the exponential distribution, the Weibull distribution and the gamma distribution) are special cases of the generalized gamma, it is sometimes used to determine which parametric model is appropriate for a given set of data. Another example is the half-normal distribution.

Characteristics
The generalized gamma distribution has two shape parameters, $$d > 0$$ and $$p > 0$$, and a scale parameter, $$a > 0$$. For non-negative x from a generalized gamma distribution, the probability density function is

f(x; a, d, p) = \frac{(p /a^d) x^{d-1} e^{-(x/a)^p}}{\Gamma(d/p)}, $$ where $$\Gamma(\cdot)$$ denotes the gamma function.

The cumulative distribution function is



F(x; a, d, p) = \frac{\gamma(d/p, (x/a)^p)}{\Gamma(d/p)}, \text{or} \, P\left( \frac{d}{p}, \left( \frac{x}{a} \right)^p \right) ; $$ where $$\gamma(\cdot)$$ denotes the lower incomplete gamma function, and $$P(\cdot, \cdot)$$ denotes the regularized lower incomplete gamma function.

The quantile function can be found by noting that $$F(x; a, d, p) = G((x/a)^p)$$ where $$G$$ is the cumulative distribution function of the gamma distribution with parameters $$\alpha = d/p$$ and $$\beta = 1$$. The quantile function is then given by inverting $$F$$ using known relations about inverse of composite functions, yielding:



F^{-1}(q; a, d, p) = a \cdot \big[ G^{-1}(q) \big]^{1/p},$$ with $$G^{-1}(q)$$ being the quantile function for a gamma distribution with $$\alpha = d/p,\, \beta = 1$$.

Related distributions

 * If $$d=p$$ then the generalized gamma distribution becomes the Weibull distribution.
 * If $$p=1$$ the generalised gamma becomes the gamma distribution.
 * If $$p=d=1$$ then it becomes the exponential distribution.
 * If $$p=d=2$$ then it becomes the Rayleigh distribution.
 * If $$p=2$$ and $$d=2m$$ then it becomes the Nakagami distribution.
 * If $$p=2$$ and $$d=1$$ then it becomes a half-normal distribution.

Alternative parameterisations of this distribution are sometimes used; for example with the substitution &alpha; =   d/p. In addition, a shift parameter can be added, so the domain of x starts at some value other than zero. If the restrictions on the signs of a, d and p are also lifted (but &alpha; = d/p remains positive), this gives a distribution called the Amoroso distribution, after the Italian mathematician and economist Luigi Amoroso who described it in 1925.

Moments
If X has a generalized gamma distribution as above, then
 * $$\operatorname{E}(X^r)= a^r \frac{\Gamma (\frac{d+r}{p})}{\Gamma( \frac{d}{p})} . $$

Properties
Denote GG(a,d,p) as the generalized gamma distribution of parameters a, d, p. Then, given $$c$$ and $$\alpha$$ two positive real numbers, if $$f \sim GG(a,d,p)$$, then $$c f\sim GG(c a,d,p)$$ and $$f^\alpha\sim GG\left(a^\alpha,\frac{d}{\alpha},\frac{p}{\alpha}\right)$$.

Kullback-Leibler divergence
If $$f_1$$ and $$f_2$$ are the probability density functions of two generalized gamma distributions, then their Kullback-Leibler divergence is given by

\begin{align} D_{KL} (f_1 \parallel f_2) & = \int_{0}^{\infty} f_1(x; a_1, d_1, p_1) \, \ln \frac{f_1(x; a_1, d_1, p_1)}{f_2(x; a_2, d_2, p_2)} \, dx\\ & = \ln \frac{p_1 \, a_2^{d_2} \, \Gamma\left(d_2 / p_2\right)}{p_2 \, a_1^{d_1} \, \Gamma\left(d_1 /p_1\right)} + \left[ \frac{\psi\left( d_1 / p_1 \right)}{p_1} + \ln a_1 \right] (d_1 - d_2) + \frac{\Gamma\bigl((d_1+p_2) / p_1 \bigr)}{\Gamma\left(d_1 / p_1\right)} \left( \frac{a_1}{a_2} \right)^{p_2} - \frac{d_1}{p_1} \end{align} $$ where $$\psi(\cdot)$$ is the digamma function.

Software implementation
In the R programming language, there are a few packages that include functions for fitting and generating generalized gamma distributions. The gamlss package in R allows for fitting and generating many different distribution families including generalized gamma (family=GG). Other options in R, implemented in the package flexsurv, include the function dgengamma, with parameterization: $$\mu=\ln a + \frac{\ln d - \ln p}{p}$$, $$\sigma=\frac{1}{\sqrt{pd}}$$, $$Q=\sqrt{\frac{p}{d}}$$, and in the package ggamma with parametrisation: $$a = a$$, $$b = p$$, $$k = d/p$$.

In the python programming language, it is implemented in the SciPy package, with parametrisation: $$c = p$$, $$a = d/p$$, and scale of 1.