Harman Patil (Editor)

Normal gamma distribution

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Parameters
  
μ {displaystyle mu ,} location (real) λ > 0 {displaystyle lambda >0,} (real) α > 0 {displaystyle alpha >0,} (real) β > 0 {displaystyle eta >0,} (real)

Support
  
x ∈ ( − ∞ , ∞ ) , τ ∈ ( 0 , ∞ ) {displaystyle xin (-infty ,infty ),!,; au in (0,infty )}

PDF
  
f ( x , τ | μ , λ , α , β ) = β α λ Γ ( α ) 2 π τ α − 1 2 e − β τ e − λ τ ( x − μ ) 2 2 {displaystyle f(x, au |mu ,lambda ,alpha ,eta )={ rac {eta ^{alpha }{sqrt {lambda }}}{Gamma (alpha ){sqrt {2pi }}}}, au ^{alpha -{ rac {1}{2}}},e^{-eta au },e^{-{ rac {lambda au (x-mu )^{2}}{2}}}}

Mean
  
E ⁡ ( X ) = μ , E ⁡ ( T ) = α β − 1 {displaystyle operatorname {E} (X)=mu ,!,quad operatorname {E} (mathrm {T} )=alpha eta ^{-1}}

Mode
  
( μ , α − 1 2 β ) {displaystyle left(mu ,{ rac {alpha -{ rac {1}{2}}}{eta }} ight)}

Variance
  
var ⁡ ( X ) = β λ ( α − 1 ) , var ⁡ ( T ) = α β − 2 {displaystyle operatorname {var} (X)={ rac {eta }{lambda (alpha -1)}},quad operatorname {var} (mathrm {T} )=alpha eta ^{-2}}

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.

Contents

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 | α , β G a m m a ( α , β ) ,

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 ) N o r m a l G a m m a ( μ , λ , α , β ) .

Probability density function

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

f ( x , τ | μ , λ , α , β ) = β α λ Γ ( α ) 2 π τ α 1 2 e β τ e λ τ ( x μ ) 2 2

Marginal distributions

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

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 , τ x 2 .

Moments of the natural statistics

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

E ( ln T ) = ψ ( α ) ln β , where ψ ( α ) is the digamma function, E ( T ) = α β , E ( T X ) = μ α β , E ( T X 2 ) = 1 λ + μ 2 α β .

Scaling

If ( X , T ) N o r m a l G a m m a ( μ , λ , α , β ) , then for any b > 0, (bX,bT) is distributed as N o r m a l G a m m a ( b μ , λ , α , b 2 β ) .

Posterior distribution of the parameters

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

x N ( μ , τ 1 )

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

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

for which the density π satisfies

π ( μ , τ ) τ α 0 1 2 exp [ β 0 τ ] exp [ λ 0 τ ( μ μ 0 ) 2 2 ] .

Given a dataset X , consisting of n independent and identically distributed random variables (i.i.d), { x 1 , . . . , x n } , the posterior distribution of μ and τ given this dataset can be analytically determined by Bayes' theorem. Explicitly,

P ( τ , μ | X ) L ( X | τ , μ ) π ( τ , μ ) ,

where L is the likelihood of the data given the parameters.

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:

L ( X | τ , μ ) = i = 1 n L ( x i | τ , μ ) .

This expression can be simplified as follows:

L ( X | τ , μ ) i = 1 n τ 1 / 2 exp [ τ 2 ( x i μ ) 2 ] τ n / 2 exp [ τ 2 i = 1 n ( x i μ ) 2 ] τ n / 2 exp [ τ 2 i = 1 n ( x i x ¯ + x ¯ μ ) 2 ] τ n / 2 exp [ τ 2 i = 1 n ( ( x i x ¯ ) 2 + ( x ¯ μ ) 2 ) ] τ n / 2 exp [ τ 2 ( n s + n ( x ¯ μ ) 2 ) ] ,

where x ¯ = 1 n i = 1 n x i , the mean of the data samples, and s = 1 n i = 1 n ( x i x ¯ ) 2 , the sample variance.

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

P ( τ , μ | X ) L ( X | τ , μ ) π ( τ , μ ) τ n / 2 exp [ τ 2 ( n s + n ( x ¯ μ ) 2 ) ] τ α 0 1 2 exp [ β 0 τ ] exp [ λ 0 τ ( μ μ 0 ) 2 2 ] τ n 2 + α 0 1 2 exp [ τ ( 1 2 n s + β 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 μ 0 2 + n μ 2 2 n x ¯ μ + n x ¯ 2 = ( λ 0 + n ) μ 2 2 ( λ 0 μ 0 + n x ¯ ) μ + λ 0 μ 0 2 + n x ¯ 2 = ( λ 0 + n ) ( μ 2 2 λ 0 μ 0 + n x ¯ λ 0 + n μ ) + λ 0 μ 0 2 + n x ¯ 2 = ( λ 0 + n ) ( μ λ 0 μ 0 + n x ¯ λ 0 + n ) 2 + λ 0 μ 0 2 + n x ¯ 2 ( λ 0 μ 0 + n x ¯ ) 2 λ 0 + n = ( λ 0 + n ) ( μ λ 0 μ 0 + n x ¯ λ 0 + n ) 2 + λ 0 n ( x ¯ μ 0 ) 2 λ 0 + n

On inserting this back into the expression above,

P ( τ , μ | X ) τ n 2 + α 0 1 2 exp [ τ ( 1 2 n s + β 0 ) ] exp [ τ 2 ( ( λ 0 + n ) ( μ λ 0 μ 0 + n x ¯ λ 0 + n ) 2 + λ 0 n ( x ¯ μ 0 ) 2 λ 0 + n ) ] τ n 2 + α 0 1 2 exp [ τ ( 1 2 n s + β 0 + λ 0 n ( x ¯ μ 0 ) 2 2 ( λ 0 + n ) ) ] exp [ τ 2 ( λ 0 + n ) ( μ λ 0 μ 0 + n x ¯ λ 0 + n ) 2 ]

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

P ( τ , μ | X ) = NormalGamma ( λ 0 μ 0 + n x ¯ λ 0 + n , λ 0 + n , α 0 + n 2 , β 0 + 1 2 ( n s + λ 0 n ( 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 up 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

    P ( τ , μ | X ) = NormalGamma ( μ 0 , n μ , n τ 2 , n τ 2 τ 0 )

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

    P ( τ , μ | X ) = NormalGamma ( n μ μ 0 + n μ n μ + n , n μ + n , 1 2 ( n τ + n ) , 1 2 ( n τ τ 0 + n s + n μ n ( μ μ 0 ) 2 n μ + 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 / ( λ τ )
  • The normal-inverse-gamma distribution is essentially the same distribution parameterized by variance rather than precision
  • The normal-exponential-gamma distribution
  • References

    Normal-gamma distribution Wikipedia