Normal-gamma distribution

From testwiki
Revision as of 03:27, 22 December 2024 by imported>GKSmyth (β†’Related distributions: it is exactly the same distribution, no need for weasel word "essentially")
(diff) ← Older revision | Latest revision (diff) | Newer revision β†’ (diff)
Jump to navigation Jump to search

Template:Short description Template:Probability distribution 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.[1]

Definition

For a pair of random variables, (X,T), suppose that the conditional distribution of X given T is given by

XTN(μ,1/(λT)),

meaning that the conditional distribution is a normal distribution with mean μ and precision λT β€” equivalently, with variance 1/(λT).

Suppose also that the marginal distribution of T is given by

Tα,βGamma(α,β),

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

(X,T)NormalGamma(μ,λ,α,β).

Properties

Probability density function

The joint probability density function of (X,T) is

f(x,τμ,λ,α,β)=βαλΓ(α)2πτα12eβτexp(λτ(xμ)22),

where the conditional probability for f(x,τμ,λ,α,β)=f(xτ,μ,λ,α,β)f(τμ,λ,α,β) was used.

Marginal distributions

By construction, the marginal distribution of τ is a gamma distribution, and the conditional distribution of x given τ is a Gaussian distribution. The marginal distribution of x is a three-parameter non-standardized Student's t-distribution with parameters (ν,μ,σ2)=(2α,μ,β/(λα)).Template:Citation needed

Exponential family

The normal-gamma distribution is a four-parameter exponential family with natural parameters α1/2,βλμ2/2,λμ,λ/2 and natural statistics lnτ,τ,τx,τx2.Template:Citation needed

Moments of the natural statistics

The following moments can be easily computed using the moment generating function of the sufficient statistic:[2]

E(lnT)=ψ(α)lnβ,

where ψ(α) is the digamma function,

E(T)=αβ,E(TX)=μαβ,E(TX2)=1λ+μ2αβ.

Scaling

If (X,T)NormalGamma(μ,λ,α,β), then for any b>0,(bX,bT) is distributed asTemplate:Citation needed NormalGamma(bμ,λ/b3,α,β/b).

Posterior distribution of the parameters

Assume that x is distributed according to a normal distribution with unknown mean μ and precision τ.

x𝒩(μ,τ1)

and that the prior distribution on μ and τ, (μ,τ), has a normal-gamma distribution

(μ,τ)NormalGamma(μ0,λ0,α0,β0),

for which the density Template:Pi satisfies

π(μ,τ)τα012exp[β0τ]exp[λ0τ(μμ0)22].

Suppose

x1,,xnμ,τi.i.d.N(μ,τ1),

i.e. the components of 𝐗=(x1,,xn) are conditionally independent given μ,τ and the conditional distribution of each of them given μ,τ is normal with expected value μ and variance 1/τ. The posterior distribution of μ and τ given this dataset 𝕏 can be analytically determined by Bayes' theorem[3] explicitly,

𝐏(τ,μ𝐗)𝐋(𝐗τ,μ)π(τ,μ),

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:

𝐋(𝐗τ,μ)=i=1n𝐋(xiτ,μ).

This expression can be simplified as follows:

𝐋(𝐗τ,μ)i=1nτ1/2exp[τ2(xiμ)2]τn/2exp[τ2i=1n(xiμ)2]τn/2exp[τ2i=1n(xixΒ―+xΒ―μ)2]τn/2exp[τ2i=1n((xixΒ―)2+(xΒ―μ)2)]τn/2exp[τ2(ns+n(xΒ―μ)2)],

where xΒ―=1ni=1nxi, the mean of the data samples, and s=1ni=1n(xixΒ―)2, the sample variance.

The posterior distribution of the parameters is proportional to the prior times the likelihood.

𝐏(τ,μ𝐗)𝐋(𝐗τ,μ)π(τ,μ)τn/2exp[τ2(ns+n(xΒ―μ)2)]τα012exp[β0τ]exp[λ0τ(μμ0)22]τn2+α012exp[τ(12ns+β0)]exp[τ2(λ0(μμ0)2+n(xΒ―μ)2)]

The final exponential term is simplified by completing the square.

λ0(μμ0)2+n(xΒ―μ)2=λ0μ22λ0μμ0+λ0μ02+nμ22nxΒ―μ+nxΒ―2=(λ0+n)μ22(λ0μ0+nxΒ―)μ+λ0μ02+nxΒ―2=(λ0+n)(μ22λ0μ0+nxΒ―λ0+nμ)+λ0μ02+nxΒ―2=(λ0+n)(μλ0μ0+nxΒ―λ0+n)2+λ0μ02+nxΒ―2(λ0μ0+nxΒ―)2λ0+n=(λ0+n)(μλ0μ0+nxΒ―λ0+n)2+λ0n(xΒ―μ0)2λ0+n

On inserting this back into the expression above,

𝐏(τ,μ𝐗)τn2+α012exp[τ(12ns+β0)]exp[τ2((λ0+n)(μλ0μ0+nxΒ―λ0+n)2+λ0n(xΒ―μ0)2λ0+n)]τn2+α012exp[τ(12ns+β0+λ0n(xΒ―μ0)22(λ0+n))]exp[τ2(λ0+n)(μλ0μ0+nxΒ―λ0+n)2]

This final expression is in exactly the same form as a Normal-Gamma distribution, i.e.,

𝐏(τ,μ𝐗)=NormalGamma(λ0μ0+nxΒ―λ0+n,λ0+n,α0+n2,β0+12(ns+λ0n(xΒ―μ0)2λ0+n))

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 2α 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 2β).
  • The posterior updates the number of pseudo-observations (λ0) simply by adding the corresponding number of new observations (n).
  • 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 μ0 from nμ samples and a prior precision of τ0 from nτ samples, the prior distribution over μ and τ is

𝐏(τ,μ𝐗)=NormalGamma(μ0,nμ,nτ2,nτ2τ0)

and after observing n samples with mean μ and variance s, the posterior probability is

𝐏(τ,μ𝐗)=NormalGamma(nμμ0+nμnμ+n,nμ+n,12(nτ+n),12(nττ0+ns+nμn(μμ0)2nμ+n))

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 2τ0/nτ.

Generating normal-gamma random variates

Generation of random variates is straightforward:

  1. Sample τ from a gamma distribution with parameters α and β
  2. Sample x from a normal distribution with mean μ and variance 1/(λτ)

Notes

Template:Reflist

References

  • Bernardo, J.M.; Smith, A.F.M. (1993) Bayesian Theory, Wiley. Template:ISBN
  • Dearden et al. "Bayesian Q-learning", Proceedings of the Fifteenth National Conference on Artificial Intelligence (AAAI-98), July 26–30, 1998, Madison, Wisconsin, USA.

Template:ProbDistributions

  1. ↑ Bernardo & Smith (1993, pages 136, 268, 434)
  2. ↑ Template:Citation
  3. ↑ Template:Cite web