# Generalized Gaussian Probability Density Function

## Density Function

The Generalized Gaussian density has the following form:

$\mathcal{GG}(x;\rho) = \frac{1}{2\, \Gamma(1+1/\rho)} \exp(-|x|^{\rho})$

where $\rho$ (rho) is the "shape parameter". The density is plotted in the following figure:

Matlab code used to generate this figure is available here: ggplot.m.

Adding an arbitrary location parameter, $\mu$, and inverse scale parameter, $\beta$, the density has the form,

$\mathcal{GG}(x;\mu,\beta,\rho) = \frac{\beta^{1\!/2}}{2\, \Gamma(1+1/\rho)} \exp(-\beta^{\rho/2}|x-\mu|^{\rho})$

Matlab code used to generate this figure is available here: ggplot2.m.

## Generating Random Samples

Samples from the Generalized Gaussian can be generated by a transformation of Gamma random samples, using the fact that if $Y$ is a $\text{Gamma}(1/\rho,1)$ distributed random variable, and $S$ is an independent random variable taking the value -1 or +1 with equal probability, then,

$X = S \cdot |Y|^{1/\rho}$

is distributed $\matcal{GG}(x;0,1,\rho)$. That is,

$\parstyle \begin{eqnarray*} Y & \sim & \text{Gamma}(1/\rho,1) \\ S & \sim & \mbox{\frac{1}{2}}\, [S=-1] + \mbox{\frac{1}{2}}\, [S=1] \\ \mu + \beta^{-1/2} S \cdot |Y|^{1/\rho} & \sim & \mathcal{GG}(x;\mu,\beta,\rho) \end{eqnarray*}$

where the density of $S$ is written in a non-standard but suggestive form.

## Matlab Code

Matlab code to generate random variates from the Generalized Gaussian density with parameters as described here is here:

As an example, we generate random samples from the example Generalized Gaussian densities shown above.

Matlab code used to generate this figure is available here: ggplot3.m.

## Mixture Densities

A more general family of densities can be constructed from mixtures of Generalized Gaussians. A mixture density, $p_M(x)$, is made up of $m$ constituent densities $p_j(x),\, j = 1,\ldots,m,$ together with probabilities $\alpha_j$ associated with each constituent density.

$p_M(x) = \sum_{j=1}^m \alpha_j p_j(x)$

The densities $p_j(x)$ have different forms, or parameter values. A random variable with a mixture density can be thought of as being generated by a two-part process: first a decision is made as to which constituent density to draw from, where the $j\text{th}$ density is chosen with probability $\alpha_j$, then the value of the random variable is drawn from the chosen density. Independent repetitions of this process result in a sample having the mixture density $p_M$.

As an example consider the density,

$\mbox{\frac{1}{2}}\,\mathcal{GG}(x;-2,1,1) + \mbox{\frac{2}{10}}\,\mathcal{GG}(x;0,1,2) + \mbox{\frac{3}{10}}\,\mathcal{GG}(x;2,1,10)$

Matlab code used to generate these figures is available here: ggplot4.m.