Family of continuous probability distributions
normal-gammaParameters | location (real)
(real)
(real)
(real) |
---|
Support | ![{\displaystyle x\in (-\infty ,\infty )\,\!,\;\tau \in (0,\infty )}](https://wikimedia.org/api/rest_v1/media/math/render/svg/6a7382e1840ba51b506dda1732892a4e60dd4769) |
---|
PDF | ![{\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}}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/99f5e93b60e8671f91c52e715eaadae7a9767624) |
---|
Mean | [1] ![{\displaystyle \operatorname {E} (X)=\mu \,\!,\quad \operatorname {E} (\mathrm {T} )=\alpha \beta ^{-1}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/c454bfd28caa0b21b05a91db5107c42689738d79) |
---|
Mode | ![{\displaystyle \left(\mu ,{\frac {\alpha -{\frac {1}{2}}}{\beta }}\right)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/c2cce2316039d737816f6386f69a0f3abee0dd35) |
---|
Variance | [1] ![{\displaystyle \operatorname {var} (X)={\Big (}{\frac {\beta }{\lambda (\alpha -1)}}{\Big )},\quad \operatorname {var} (\mathrm {T} )=\alpha \beta ^{-2}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/d1a461a2810bbd9433fee7603058e89e13fd0b94) |
---|
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
![{\displaystyle X\mid T\sim N(\mu ,1/(\lambda T))\,\!,}](https://wikimedia.org/api/rest_v1/media/math/render/svg/1187a63530e8681f9705356f5093acbcfccc2840)
meaning that the conditional distribution is a normal distribution with mean
and precision
— equivalently, with variance
Suppose also that the marginal distribution of T is given by
![{\displaystyle T\mid \alpha ,\beta \sim \operatorname {Gamma} (\alpha ,\beta ),}](https://wikimedia.org/api/rest_v1/media/math/render/svg/5aa00dfd30ec3b2284389f9f98058058f9706017)
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
![{\displaystyle (X,T)\sim \operatorname {NormalGamma} (\mu ,\lambda ,\alpha ,\beta ).}](https://wikimedia.org/api/rest_v1/media/math/render/svg/6f9887a7fe8e1b9bf1a676afa0dc71439c73604b)
Properties
Probability density function
The joint probability density function of (X,T) is[citation needed]
![{\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)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/1b872b1a39b41f9ed2f8b8645c2a9d2bdbc27058)
Marginal distributions
By construction, the marginal distribution of
is a gamma distribution, and the conditional distribution of
given
is a Gaussian distribution. The marginal distribution of
is a three-parameter non-standardized Student's t-distribution with parameters
.[citation needed]
Exponential family
The normal-gamma distribution is a four-parameter exponential family with natural parameters
and natural statistics
.[citation needed]
Moments of the natural statistics
The following moments can be easily computed using the moment generating function of the sufficient statistic:[3]
![{\displaystyle \operatorname {E} (\ln T)=\psi \left(\alpha \right)-\ln \beta ,}](https://wikimedia.org/api/rest_v1/media/math/render/svg/b78c35719120b4382eb1c67342ab33c73ee77386)
where
is the digamma function,
![{\displaystyle {\begin{aligned}\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{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/1ef647cdd696ae61d9c036810faeef8cb088c096)
Scaling
If
then for any
is distributed as[citation needed]
Posterior distribution of the parameters
Assume that x is distributed according to a normal distribution with unknown mean
and precision
.
![{\displaystyle x\sim {\mathcal {N}}(\mu ,\tau ^{-1})}](https://wikimedia.org/api/rest_v1/media/math/render/svg/985660687f2f31e451fc2ef102e0f79e28d34aad)
and that the prior distribution on
and
,
, has a normal-gamma distribution
![{\displaystyle (\mu ,\tau )\sim {\text{NormalGamma}}(\mu _{0},\lambda _{0},\alpha _{0},\beta _{0}),}](https://wikimedia.org/api/rest_v1/media/math/render/svg/3119a6fc542ea9bf21e88b29a4c53295f96e7653)
for which the density π satisfies
![{\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].}](https://wikimedia.org/api/rest_v1/media/math/render/svg/beb41e025bfbe7ea2f4087b48af2f9fb48b9c172)
Suppose
![{\displaystyle x_{1},\ldots ,x_{n}\mid \mu ,\tau \sim \operatorname {{i.}{i.}{d.}} \operatorname {N} \left(\mu ,\tau ^{-1}\right),}](https://wikimedia.org/api/rest_v1/media/math/render/svg/c2629b636171644d12ab8fd476eee369bf759f9c)
i.e. the components of
are conditionally independent given
and the conditional distribution of each of them given
is normal with expected value
and variance
The posterior distribution of
and
given this dataset
can be analytically determined by Bayes' theorem[4] explicitly,
![{\displaystyle \mathbf {P} (\tau ,\mu \mid \mathbf {X} )\propto \mathbf {L} (\mathbf {X} \mid \tau ,\mu )\pi (\tau ,\mu ),}](https://wikimedia.org/api/rest_v1/media/math/render/svg/3bb8c8f36e2a342a2fbbfda2beb071db5d3fb139)
where
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:
![{\displaystyle \mathbf {L} (\mathbf {X} \mid \tau ,\mu )=\prod _{i=1}^{n}\mathbf {L} (x_{i}\mid \tau ,\mu ).}](https://wikimedia.org/api/rest_v1/media/math/render/svg/1263d04da05d6facba00b65beda2e3d128f1972c)
This expression can be simplified as follows:
![{\displaystyle {\begin{aligned}\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(ns+n({\bar {x}}-\mu )^{2}\right)\right],\end{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/2af15facc697809f43f699f3db0ff784f59dea45)
where
, the mean of the data samples, and
, the sample variance.
The posterior distribution of the parameters is proportional to the prior times the likelihood.
![{\displaystyle {\begin{aligned}\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(ns+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}}ns+\beta _{0}\right)\right]\exp \left[-{\frac {\tau }{2}}\left(\lambda _{0}(\mu -\mu _{0})^{2}+n({\bar {x}}-\mu )^{2}\right)\right]\end{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/de9c451b7469721ab4ef04a1df37564f2a9ad70b)
The final exponential term is simplified by completing the square.
![{\displaystyle {\begin{aligned}\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}-2n{\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{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/ceddb6e185fdfe4036eec5b44b3a0195c8649f75)
On inserting this back into the expression above,
![{\displaystyle {\begin{aligned}\mathbf {P} (\tau ,\mu \mid \mathbf {X} )&\propto \tau ^{{\frac {n}{2}}+\alpha _{0}-{\frac {1}{2}}}\exp \left[-\tau \left({\frac {1}{2}}ns+\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}}ns+\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{aligned}}}](https://wikimedia.org/api/rest_v1/media/math/render/svg/be3f6e839a36bd0b1ccaf4ed857d7389eb834b50)
This final expression is in exactly the same form as a Normal-Gamma distribution, i.e.,
![{\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(ns+{\frac {\lambda _{0}n({\bar {x}}-\mu _{0})^{2}}{\lambda _{0}+n}}\right)\right)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/5365a93edcb76643ad1fb34e87d5b60e12b577d7)
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
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
and sample variance
(i.e. with sum of squared deviations
). - The posterior updates the number of pseudo-observations (
) simply by adding the corresponding number of new observations (
). - 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
from
samples and a prior precision of
from
samples, the prior distribution over
and
is
![{\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)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/52c231fee808534bff66ff32f8fbc3e4ede3f990)
and after observing
samples with mean
and variance
, the posterior probability is
![{\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}}}+ns+{\frac {n_{\mu }n(\mu -\mu _{0})^{2}}{n_{\mu }+n}}\right)\right)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/40f213d9ba6432e5273f2bb00a2685fcc5e2ad85)
Note that in some programming languages, such as Matlab, the gamma distribution is implemented with the inverse definition of
, so the fourth argument of the Normal-Gamma distribution is
.
Generating normal-gamma random variates
Generation of random variates is straightforward:
- Sample
from a gamma distribution with parameters
and ![{\displaystyle \beta }](https://wikimedia.org/api/rest_v1/media/math/render/svg/7ed48a5e36207156fb792fa79d29925d2f7901e8)
- Sample
from a normal distribution with mean
and variance ![{\displaystyle 1/(\lambda \tau )}](https://wikimedia.org/api/rest_v1/media/math/render/svg/eb9e39838510315a7120cad70e868d94b9090179)
Notes
- ^ a b 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, retrieved 2023-12-08
- ^ "Bayes' Theorem: Introduction". Archived from the original on 2014-08-07. Retrieved 2014-08-05.
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.
Discrete univariate | with finite support | |
---|
with infinite support | |
---|
|
---|
Continuous univariate | supported on a bounded interval | |
---|
supported on a semi-infinite interval | |
---|
supported on the whole real line | |
---|
with support whose type varies | |
---|
|
---|
Mixed univariate | |
---|
Multivariate (joint) | |
---|
Directional | |
---|
Degenerate and singular | |
---|
Families | |
---|
Category Commons |