Normal-gamma distribution

From testwiki
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

X∣T∼N(μ,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⁡(ln⁡T)=ψ(α)−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

π(μ,τ)∝τα0−12exp⁡[−β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⁡[−τ2∑i=1n(xi−μ)2]∝τn/2exp⁡[−τ2∑i=1n(xi−x¯+x¯−μ)2]∝τn/2exp⁡[−τ2∑i=1n((xi−x¯)2+(x¯−μ)2)]∝τn/2exp⁡[−τ2(ns+n(x¯−μ)2)],

where x¯=1n∑i=1nxi, the mean of the data samples, and s=1n∑i=1n(xi−x¯)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)]τα0−12exp⁡[−β0τ]exp⁡[−λ0τ(μ−μ0)22]∝τn2+α0−12exp⁡[−τ(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μ2−2λ0μμ0+λ0μ02+nμ2−2nx¯μ+nx¯2=(λ0+n)μ2−2(λ0μ0+nx¯)μ+λ0μ02+nx¯2=(λ0+n)(μ2−2λ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+α0−12exp⁡[−τ(12ns+β0)]exp⁡[−τ2((λ0+n)(μ−λ0μ0+nx¯λ0+n)2+λ0n(x¯−μ0)2λ0+n)]∝τn2+α0−12exp⁡[−τ(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

Template:ProbDistributions