Skip to content

Commit

Permalink
Documentation normal-inverse-gamma conjugate prior distribution and n…
Browse files Browse the repository at this point in the history
…ormal model
  • Loading branch information
guillermo-navas-palencia committed Oct 6, 2019
1 parent 851b269 commit 86b590c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
29 changes: 29 additions & 0 deletions doc/source/conjugate_normal_inverse_gamma.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
Normal-inverse-gamma distribution
=================================

The probability density function of the normal-inverse gamma distribution
:math:`\mathcal{N}\Gamma^{-1}(\mu, \lambda, \alpha, \beta)` with location
parameter :math:`\mu`, variance scale parameter :math:`\lambda > 0`, shape
parameter :math:`\alpha > 0` and scale parameter :math:`\beta > 0,` for
:math:`x \in \mathbb{R}` and :math:`\sigma^2 \in \mathbb{R}^+`, is given by

.. math::
f(x,\sigma^2; \mu,\lambda,\alpha,\beta) = \frac {\sqrt{\lambda}} {\sigma\sqrt{2\pi} } \, \frac{\beta^\alpha}{\Gamma(\alpha)} \, \left( \frac{1}{\sigma^2} \right)^{\alpha + 1} \exp \left( -\frac { 2\beta + \lambda(x - \mu)^2} {2\sigma^2} \right),
and the cumulative distribution function is

.. math::
F(x,\sigma^2; \mu,\lambda,\alpha,\beta) = \frac{e^{-\frac{\beta}{\sigma^2}} \left(\frac{\beta }{\sigma ^2}\right)^\alpha
\left(\operatorname{erf}\left(\frac{\sqrt{\lambda} (x-\mu )}{\sqrt{2} \sigma }\right)+1\right)}{2
\sigma^2 \Gamma (\alpha)}.
The expected value and variance are as follows

.. math::
\mathrm{E}[x] &= \mu, \quad \mathrm{E}[\sigma^2] = \frac{\beta}{\alpha-1}, \; \alpha > 1.
\mathrm{Var}[x] &= \frac{\beta}{(\alpha - 1)\lambda}, \; \alpha > 1,
\quad \mathrm{Var}[\sigma^2] = \frac{\beta^2}{(\alpha-1)^2(\alpha - 2)}, \; \alpha > 2.
The normal-inverse-gamma distribution is used as a conjugate prior distribution for
the normal distribution with unknown mean and variance.


.. autoclass:: cprior.cdist.NormalInverseGammaModel
Expand Down
50 changes: 49 additions & 1 deletion doc/source/formulas_models_normal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,62 @@ Normal-normal-inverse-gamma conjugate model
Posterior predictive distribution
---------------------------------

If :math:`X| \mu, \sigma^2 \sim \mathcal{N}(\mu, \sigma^2)` with
:math:`(\mu, \sigma) \sim \mathcal{N}\Gamma^{-1}(\mu_0, \lambda, \alpha, \beta)`,
then the posterior predictive probability density function, the expected
value and variance of :math:`X` are

.. math::
f(x; \mu_0, \lambda, \alpha, \beta) = \frac{\alpha}{\beta(1 + \lambda^{-1})}
\frac{\left(1 + \frac{1}{2\alpha} \left(\frac{\alpha(x - \mu_0)}{\beta(1+\lambda^{-1})} \right)^2 \right)^{-\alpha - 1/2}}
{\sqrt{2\alpha}B(\alpha, 1/2)},
.. math::
\mathrm{E}[X] = \mu_0, \quad \mathrm{Var}[X] = \frac{\left(\beta(1 +
\lambda^{-1})\right)^2}{\alpha(\alpha - 1)},
where :math:`\mathrm{E}[X]` is defined for :math:`\alpha > 1/2` and
:math:`\mathrm{Var}[X]` is defined for :math:`\alpha > 1`.


Proofs
------

Posterior predictive probability density function

Note that this is the probability density function of the
Student's t-distribution, thus

.. math::
X \sim t_{2 \alpha}\left(\mu_0, \frac{\beta (1 + \lambda^{-1})}{\alpha}\right),
see :cite:`Murphy2007`.


Posterior predictive expected value

Apply properties of the Student's t-distribution.

.. math ::
\mathrm{E}[X] = \mu_0.
Posterior predictive variance

Apply properties of the Student's t-distribution.

.. math::
\mathrm{Var}[X] = \frac{\left(\beta(1 +
\lambda^{-1})\right)^2}{\alpha(\alpha - 1)}.
References
----------

Posterior predictive variance
.. bibliography:: refs.bib
:filter: docname in docnames
2 changes: 1 addition & 1 deletion doc/source/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @article{Miller2015

@article{Murphy2007,
title = {{Conjugate Bayesian analysis of the Gaussian distribution}},
author = {Murphy, Kevin P.},
author = {Murphy, K. P.},
journal = {},
year = {2007},
url = {https://www.cs.ubc.ca/~murphyk/Papers/bayesGauss.pdf}
Expand Down

0 comments on commit 86b590c

Please sign in to comment.