Normal-gamma distribution
Parameters |
[math]\displaystyle{ \mu\, }[/math] location (real) [math]\displaystyle{ \lambda \gt 0\, }[/math] (real) [math]\displaystyle{ \alpha \gt 0\, }[/math] (real) [math]\displaystyle{ \beta \gt 0\, }[/math] (real) | ||
---|---|---|---|
Support | [math]\displaystyle{ x \in (-\infty, \infty)\,\!, \; \tau \in (0,\infty) }[/math] | ||
[math]\displaystyle{ f(x,\tau\mid\mu,\lambda,\alpha,\beta) = \frac{\beta^\alpha \sqrt{\lambda}}{\Gamma(\alpha)\sqrt{2\pi}} \, \tau^{\alpha-\frac{1}{2}}\,e^{-\beta\tau}\,e^{ -\frac{ \lambda \tau (x- \mu)^2}{2}} }[/math] | |||
Mean | [1] [math]\displaystyle{ \operatorname{E}(X)=\mu\,\! ,\quad \operatorname{E}(\Tau)= \alpha \beta^{-1} }[/math] | ||
Mode | [math]\displaystyle{ \left(\mu, \frac{\alpha - \frac12}{\beta}\right) }[/math] | ||
Variance | [1] [math]\displaystyle{ \operatorname{var}(X)= \Big(\frac{\beta}{\lambda (\alpha-1)}\Big) ,\quad \operatorname{var}(\Tau)=\alpha \beta^{-2} }[/math] |
In probability theory and statistics, the normal-gamma distribution (or Gaussian-gamma distribution) is a bivariate four-parameter family of continuous probability distributions. It is the conjugate prior of a normal distribution with unknown mean and precision.[2]
Definition
For a pair of random variables, (X,T), suppose that the conditional distribution of X given T is given by
- [math]\displaystyle{ X\mid T \sim N(\mu,1 /(\lambda T)) \,\! , }[/math]
meaning that the conditional distribution is a normal distribution with mean [math]\displaystyle{ \mu }[/math] and precision [math]\displaystyle{ \lambda T }[/math] — equivalently, with variance [math]\displaystyle{ 1 / (\lambda T) . }[/math]
Suppose also that the marginal distribution of T is given by
- [math]\displaystyle{ T \mid \alpha, \beta \sim \operatorname{Gamma}(\alpha,\beta), }[/math]
where this means that T has a gamma distribution. Here λ, α and β are parameters of the joint distribution.
Then (X,T) has a normal-gamma distribution, and this is denoted by
- [math]\displaystyle{ (X,T) \sim \operatorname{NormalGamma}(\mu,\lambda,\alpha,\beta). }[/math]
Properties
Probability density function
The joint probability density function of (X,T) is[citation needed]
- [math]\displaystyle{ f(x,\tau\mid\mu,\lambda,\alpha,\beta) = \frac{\beta^\alpha \sqrt{\lambda}}{\Gamma(\alpha)\sqrt{2\pi}} \, \tau^{\alpha-\frac{1}{2}}\,e^{-\beta\tau}\exp\left( -\frac{ \lambda \tau (x- \mu)^2}{2}\right) }[/math]
Marginal distributions
By construction, the marginal distribution of [math]\displaystyle{ \tau }[/math] is a gamma distribution, and the conditional distribution of [math]\displaystyle{ x }[/math] given [math]\displaystyle{ \tau }[/math] is a Gaussian distribution. The marginal distribution of [math]\displaystyle{ x }[/math] is a three-parameter non-standardized Student's t-distribution with parameters [math]\displaystyle{ (\nu, \mu, \sigma^2)=(2\alpha, \mu, \beta/(\lambda\alpha)) }[/math].[citation needed]
Exponential family
The normal-gamma distribution is a four-parameter exponential family with natural parameters [math]\displaystyle{ \alpha-1/2, -\beta-\lambda\mu^2/2, \lambda\mu, -\lambda/2 }[/math] and natural statistics [math]\displaystyle{ \ln\tau, \tau, \tau x, \tau x^2 }[/math].[citation needed]
Moments of the natural statistics
The following moments can be easily computed using the moment generating function of the sufficient statistic:[3]
- [math]\displaystyle{ \operatorname{E}(\ln T)=\psi\left(\alpha\right) - \ln\beta, }[/math]
where [math]\displaystyle{ \psi\left(\alpha\right) }[/math] is the digamma function,
- [math]\displaystyle{ \begin{align} \operatorname{E}(T) & =\frac{\alpha}{\beta}, \\[5pt] \operatorname{E}(TX) & =\mu \frac{\alpha}{\beta}, \\[5pt] \operatorname{E}(TX^2) & =\frac{1}{\lambda} + \mu^2 \frac{\alpha}{\beta}. \end{align} }[/math]
Scaling
If [math]\displaystyle{ (X,T) \sim \mathrm{NormalGamma}(\mu,\lambda,\alpha,\beta), }[/math] then for any [math]\displaystyle{ b\gt 0, (bX,bT) }[/math] is distributed as[citation needed] [math]\displaystyle{ {\rm NormalGamma}(b\mu, \lambda/ b^3, \alpha, \beta/ b ). }[/math]
Posterior distribution of the parameters
Assume that x is distributed according to a normal distribution with unknown mean [math]\displaystyle{ \mu }[/math] and precision [math]\displaystyle{ \tau }[/math].
- [math]\displaystyle{ x \sim \mathcal{N}(\mu, \tau^{-1}) }[/math]
and that the prior distribution on [math]\displaystyle{ \mu }[/math] and [math]\displaystyle{ \tau }[/math], [math]\displaystyle{ (\mu,\tau) }[/math], has a normal-gamma distribution
- [math]\displaystyle{ (\mu,\tau) \sim \text{NormalGamma}(\mu_0,\lambda_0,\alpha_0,\beta_0) , }[/math]
for which the density π satisfies
- [math]\displaystyle{ \pi(\mu,\tau) \propto \tau^{\alpha_0-\frac{1}{2}}\,\exp[-\beta_0\tau]\,\exp\left[ -\frac{\lambda_0\tau(\mu-\mu_0)^2} 2 \right]. }[/math]
Suppose
- [math]\displaystyle{ x_1,\ldots,x_n \mid \mu,\tau \sim \operatorname{{i.}{i.}{d.}} \operatorname N\left( \mu, \tau^{-1} \right), }[/math]
i.e. the components of [math]\displaystyle{ \mathbf X = (x_1,\ldots,x_n) }[/math] are conditionally independent given [math]\displaystyle{ \mu,\tau }[/math] and the conditional distribution of each of them given [math]\displaystyle{ \mu,\tau }[/math] is normal with expected value [math]\displaystyle{ \mu }[/math] and variance [math]\displaystyle{ 1 / \tau. }[/math] The posterior distribution of [math]\displaystyle{ \mu }[/math] and [math]\displaystyle{ \tau }[/math] given this dataset [math]\displaystyle{ \mathbb X }[/math] can be analytically determined by Bayes' theorem[4] explicitly,
- [math]\displaystyle{ \mathbf{P}(\tau,\mu \mid \mathbf{X}) \propto \mathbf{L}(\mathbf{X} \mid \tau,\mu) \pi(\tau,\mu), }[/math]
where [math]\displaystyle{ \mathbf{L} }[/math] is the likelihood of the parameters given the data.
Since the data are i.i.d, the likelihood of the entire dataset is equal to the product of the likelihoods of the individual data samples:
- [math]\displaystyle{ \mathbf{L}(\mathbf{X} \mid \tau, \mu) = \prod_{i=1}^n \mathbf{L}(x_i \mid \tau, \mu). }[/math]
This expression can be simplified as follows:
- [math]\displaystyle{ \begin{align} \mathbf{L}(\mathbf{X} \mid \tau, \mu) & \propto \prod_{i=1}^n \tau^{1/2} \exp\left[\frac{-\tau}{2}(x_i-\mu)^2\right] \\[5pt] & \propto \tau^{n/2} \exp\left[\frac{-\tau}{2}\sum_{i=1}^n(x_i-\mu)^2\right] \\[5pt] & \propto \tau^{n/2} \exp\left[\frac{-\tau}{2} \sum_{i=1}^n(x_i-\bar{x} +\bar{x} -\mu)^2 \right] \\[5pt] & \propto \tau^{n/2} \exp\left[\frac{-\tau} 2 \sum_{i=1}^n \left((x_i-\bar{x})^2 + (\bar{x} -\mu)^2 \right)\right] \\[5pt] & \propto \tau^{n/2} \exp\left[\frac{-\tau}{2}\left(n s + n(\bar{x} -\mu)^2\right)\right], \end{align} }[/math]
where [math]\displaystyle{ \bar{x}= \frac{1}{n}\sum_{i=1}^n x_i }[/math], the mean of the data samples, and [math]\displaystyle{ s= \frac{1}{n} \sum_{i=1}^n(x_i-\bar{x})^2 }[/math], the sample variance.
The posterior distribution of the parameters is proportional to the prior times the likelihood.
- [math]\displaystyle{ \begin{align} \mathbf{P}(\tau, \mu \mid \mathbf{X}) &\propto \mathbf{L}(\mathbf{X} \mid \tau,\mu) \pi(\tau,\mu) \\ &\propto \tau^{n/2} \exp \left[ \frac{-\tau}{2}\left(n s + n(\bar{x} -\mu)^2\right) \right] \tau^{\alpha_0-\frac{1}{2}}\,\exp[{-\beta_0\tau}]\,\exp\left[-\frac{\lambda_0\tau(\mu-\mu_0)^2}{2}\right] \\ &\propto \tau^{\frac{n}{2} + \alpha_0 - \frac{1}{2}}\exp\left[-\tau \left( \frac{1}{2} n s + \beta_0 \right) \right] \exp\left[- \frac{\tau}{2}\left(\lambda_0(\mu-\mu_0)^2 + n(\bar{x} -\mu)^2\right)\right] \end{align} }[/math]
The final exponential term is simplified by completing the square.
- [math]\displaystyle{ \begin{align} \lambda_0(\mu-\mu_0)^2 + n(\bar{x} -\mu)^2&=\lambda_0 \mu^2 - 2 \lambda_0 \mu \mu_0 + \lambda_0 \mu_0^2 + n \mu^2 - 2 n \bar{x} \mu + n \bar{x}^2 \\ &= (\lambda_0 + n) \mu^2 - 2(\lambda_0 \mu_0 + n \bar{x}) \mu + \lambda_0 \mu_0^2 +n \bar{x}^2 \\ &= (\lambda_0 + n)( \mu^2 - 2 \frac{\lambda_0 \mu_0 + n \bar{x}}{\lambda_0 + n} \mu ) + \lambda_0 \mu_0^2 +n \bar{x}^2 \\ &= (\lambda_0 + n)\left(\mu - \frac{\lambda_0 \mu_0 + n \bar{x}}{\lambda_0 + n} \right) ^2 + \lambda_0 \mu_0^2 +n \bar{x}^2 - \frac{\left(\lambda_0 \mu_0 +n \bar{x}\right)^2} {\lambda_0 + n} \\ &= (\lambda_0 + n)\left(\mu - \frac{\lambda_0 \mu_0 + n \bar{x}}{\lambda_0 + n} \right) ^2 + \frac{\lambda_0 n (\bar{x} - \mu_0 )^2}{\lambda_0 +n} \end{align} }[/math]
On inserting this back into the expression above,
- [math]\displaystyle{ \begin{align} \mathbf{P}(\tau, \mu \mid \mathbf{X}) & \propto \tau^{\frac{n}{2} + \alpha_0 - \frac{1}{2}} \exp \left[-\tau \left( \frac{1}{2} n s + \beta_0 \right) \right] \exp \left[- \frac{\tau}{2} \left( \left(\lambda_0 + n \right) \left(\mu- \frac{\lambda_0 \mu_0 + n \bar{x}}{\lambda_0 + n} \right)^2 + \frac{\lambda_0 n (\bar{x} - \mu_0 )^2}{\lambda_0 +n} \right) \right]\\ & \propto \tau^{\frac{n}{2} + \alpha_0 - \frac{1}{2}} \exp \left[-\tau \left( \frac{1}{2} n s + \beta_0 + \frac{\lambda_0 n (\bar{x} - \mu_0 )^2}{2(\lambda_0 +n)} \right) \right] \exp \left[- \frac{\tau}{2} \left(\lambda_0 + n \right) \left(\mu- \frac{\lambda_0 \mu_0 + n \bar{x}}{\lambda_0 + n} \right)^2 \right] \end{align} }[/math]
This final expression is in exactly the same form as a Normal-Gamma distribution, i.e.,
- [math]\displaystyle{ \mathbf{P}(\tau, \mu \mid \mathbf{X}) = \text{NormalGamma}\left(\frac{\lambda_0 \mu_0 + n \bar{x}}{\lambda_0 + n}, \lambda_0 + n, \alpha_0+\frac{n}{2}, \beta_0+ \frac{1}{2}\left(n s + \frac{\lambda_0 n (\bar{x} - \mu_0 )^2}{\lambda_0 +n} \right) \right) }[/math]
Interpretation of parameters
The interpretation of parameters in terms of pseudo-observations is as follows:
- The new mean takes a weighted average of the old pseudo-mean and the observed mean, weighted by the number of associated (pseudo-)observations.
- The precision was estimated from [math]\displaystyle{ 2\alpha }[/math] pseudo-observations (i.e. possibly a different number of pseudo-observations, to allow the variance of the mean and precision to be controlled separately) with sample mean [math]\displaystyle{ \mu }[/math] and sample variance [math]\displaystyle{ \frac{\beta}{\alpha} }[/math] (i.e. with sum of squared deviations [math]\displaystyle{ 2\beta }[/math]).
- The posterior updates the number of pseudo-observations ([math]\displaystyle{ \lambda_{0} }[/math]) simply by adding the corresponding number of new observations ([math]\displaystyle{ n }[/math]).
- The new sum of squared deviations is computed by adding the previous respective sums of squared deviations. However, a third "interaction term" is needed because the two sets of squared deviations were computed with respect to different means, and hence the sum of the two underestimates the actual total squared deviation.
As a consequence, if one has a prior mean of [math]\displaystyle{ \mu_0 }[/math] from [math]\displaystyle{ n_\mu }[/math] samples and a prior precision of [math]\displaystyle{ \tau_0 }[/math] from [math]\displaystyle{ n_\tau }[/math] samples, the prior distribution over [math]\displaystyle{ \mu }[/math] and [math]\displaystyle{ \tau }[/math] is
- [math]\displaystyle{ \mathbf{P}(\tau,\mu \mid \mathbf{X}) = \operatorname{NormalGamma} \left(\mu_0, n_\mu , \frac{n_\tau}{2}, \frac{n_\tau}{2 \tau_0}\right) }[/math]
and after observing [math]\displaystyle{ n }[/math] samples with mean [math]\displaystyle{ \mu }[/math] and variance [math]\displaystyle{ s }[/math], the posterior probability is
- [math]\displaystyle{ \mathbf{P}(\tau,\mu \mid \mathbf{X}) = \text{NormalGamma}\left( \frac{n_\mu \mu_0 + n \mu}{n_\mu +n}, n_\mu +n ,\frac{1}{2}(n_\tau+n), \frac{1}{2}\left(\frac{n_\tau}{\tau_0} + n s + \frac{n_\mu n (\mu-\mu_0)^2}{n_\mu+n}\right) \right) }[/math]
Note that in some programming languages, such as Matlab, the gamma distribution is implemented with the inverse definition of [math]\displaystyle{ \beta }[/math], so the fourth argument of the Normal-Gamma distribution is [math]\displaystyle{ 2 \tau_0 /n_\tau }[/math].
Generating normal-gamma random variates
Generation of random variates is straightforward:
- Sample [math]\displaystyle{ \tau }[/math] from a gamma distribution with parameters [math]\displaystyle{ \alpha }[/math] and [math]\displaystyle{ \beta }[/math]
- Sample [math]\displaystyle{ x }[/math] from a normal distribution with mean [math]\displaystyle{ \mu }[/math] and variance [math]\displaystyle{ 1/(\lambda \tau) }[/math]
Related distributions
- The normal-inverse-gamma distribution is essentially the same distribution parameterized by variance rather than precision
- The normal-exponential-gamma distribution
Notes
- ↑ 1.0 1.1 Bernardo & Smith (1993, p. 434)
- ↑ Bernardo & Smith (1993, pages 136, 268, 434)
- ↑ Wasserman, Larry (2004), "Parametric Inference", Springer Texts in Statistics (New York, NY: Springer New York): pp. 119–148, ISBN 978-1-4419-2322-6, http://dx.doi.org/10.1007/978-0-387-21736-9_9, retrieved 2023-12-08
- ↑ "Bayes' Theorem: Introduction". http://www.trinity.edu/cbrown/bayesweb/.
References
- Bernardo, J.M.; Smith, A.F.M. (1993) Bayesian Theory, Wiley. ISBN:0-471-49464-X
- Dearden et al. "Bayesian Q-learning", Proceedings of the Fifteenth National Conference on Artificial Intelligence (AAAI-98), July 26–30, 1998, Madison, Wisconsin, USA.
Original source: https://en.wikipedia.org/wiki/Normal-gamma distribution.
Read more |