information:filtering
With known variance

For a set of i.i.d. normally distributed data points X of size n where each individual point x follows x ∼ N (μ, σ 2) {\textstyle x\sim {\mathcal {N}}(\mu,\sigma ^{2})} with known variance σ, the conjugate prior distribution is also normally distributed.

This can be shown more easily by rewriting the variance as the precision, i.e. using τ = 1/σ. Then if x ∼ N (μ, 1 / τ) {\textstyle x\sim {\mathcal {N}}(\mu,1/\tau)} and μ ∼ N (μ 0, 1 / τ 0), {\textstyle \mu \sim {\mathcal {N}}(\mu _{0},1/\tau _{0}),} we proceed as follows.

First, the likelihood function is (using the formula above for the sum of differences from the mean):

p (X ∣ μ, τ) = ∏ i = 1 n τ 2 π exp (− 1 2 τ (x i − μ) 2) = (τ 2 π) n / 2 exp (− 1 2 τ ∑ i = 1 n (x i − μ) 2) = (τ 2 π) n / 2 exp. {\displaystyle {\begin{aligned}p(\mathbf {X} \mid \mu,\tau)&=\prod _{i=1}^{n}{\sqrt {\frac {\tau }{2\pi }}}\exp \left(-{\frac {1}{2}}\tau (x_{i}-\mu)^{2}\right)\\&=\left({\frac {\tau }{2\pi }}\right)^{n/2}\exp \left(-{\frac {1}{2}}\tau \sum _{i=1}^{n}(x_{i}-\mu)^{2}\right)\\&=\left({\frac {\tau }{2\pi }}\right)^{n/2}\exp \left.\end{aligned}}}

Then, we proceed as follows:

p (μ ∣ X) ∝ p (X ∣ μ) p (μ) = (τ 2 π) n / 2 exp τ 0 2 π exp (− 1 2 τ 0 (μ − μ 0) 2) ∝ exp (− 1 2 (τ (∑ i = 1 n (x i − x ¯) 2 + n (x ¯ − μ) 2) + τ 0 (μ − μ 0) 2)) ∝ exp (− 1 2 (n τ (x ¯ − μ) 2 + τ 0 (μ − μ 0) 2)) = exp (− 1 2 (n τ + τ 0) (μ − n τ x ¯ + τ 0 μ 0 n τ + τ 0) 2 + n τ τ 0 n τ + τ 0 (x ¯ − μ 0) 2) ∝ exp (− 1 2 (n τ + τ 0) (μ − n τ x ¯ + τ 0 μ 0 n τ + τ 0) 2) {\displaystyle {\begin{aligned}p(\mu \mid \mathbf {X})&\propto p(\mathbf {X} \mid \mu)p(\mu)\\&=\left({\frac {\tau }{2\pi }}\right)^{n/2}\exp \left{\sqrt {\frac {\tau _{0}}{2\pi }}}\exp \left(-{\frac {1}{2}}\tau _{0}(\mu -\mu _{0})^{2}\right)\\&\propto \exp \left(-{\frac {1}{2}}\left(\tau \left(\sum _{i=1}^{n}(x_{i}-{\bar {x}})^{2}+n({\bar {x}}-\mu)^{2}\right)+\tau _{0}(\mu -\mu _{0})^{2}\right)\right)\\&\propto \exp \left(-{\frac {1}{2}}\left(n\tau ({\bar {x}}-\mu)^{2}+\tau _{0}(\mu -\mu _{0})^{2}\right)\right)\\&=\exp \left(-{\frac {1}{2}}(n\tau +\tau _{0})\left(\mu -{\dfrac {n\tau {\bar {x}}+\tau _{0}\mu _{0}}{n\tau +\tau _{0}}}\right)^{2}+{\frac {n\tau \tau _{0}}{n\tau +\tau _{0}}}({\bar {x}}-\mu _{0})^{2}\right)\\&\propto \exp \left(-{\frac {1}{2}}(n\tau +\tau _{0})\left(\mu -{\dfrac {n\tau {\bar {x}}+\tau _{0}\mu _{0}}{n\tau +\tau _{0}}}\right)^{2}\right)\end{aligned}}}

In the above derivation, we used the formula above for the sum of two quadratics and eliminated all constant factors not involving μ. The result is the kernel of a normal distribution, with mean n τ x ¯ + τ 0 μ 0 n τ + τ 0 {\textstyle {\frac {n\tau {\bar {x}}+\tau _{0}\mu _{0}}{n\tau +\tau _{0}}}} and precision n τ + τ 0 {\textstyle n\tau +\tau _{0}}, i.e.

p (μ ∣ X) ∼ N (n τ x ¯ + τ 0 μ 0 n τ + τ 0, 1 n τ + τ 0) {\displaystyle p(\mu \mid \mathbf {X})\sim {\mathcal {N}}\left({\frac {n\tau {\bar {x}}+\tau _{0}\mu _{0}}{n\tau +\tau _{0}}},{\frac {1}{n\tau +\tau _{0}}}\right)}

This can be written as a set of Bayesian update equations for the posterior parameters in terms of the prior parameters:

τ 0 ′ = τ 0 + n τ μ 0 ′ = n τ x ¯ + τ 0 μ 0 n τ + τ 0 x ¯ = 1 n ∑ i = 1 n x i {\displaystyle {\begin{aligned}\tau _{0}'&=\tau _{0}+n\tau \\\mu _{0}'&={\frac {n\tau {\bar {x}}+\tau _{0}\mu _{0}}{n\tau +\tau _{0}}}\\{\bar {x}}&={\frac {1}{n}}\sum _{i=1}^{n}x_{i}\end{aligned}}}

That is, to combine n data points with total precision of nτ (or equivalently, total variance of n / σ) and mean of values x ¯ {\textstyle {\bar {x}}}, derive a new total precision simply by adding the total precision of the data to the prior total precision, and form a new mean through a precision-weighted average, i.e. a weighted average of the data mean and the prior mean, each weighted by the associated total precision. This makes logical sense if the precision is thought of as indicating the certainty of the observations: In the distribution of the posterior mean, each of the input components is weighted by its certainty, and the certainty of this distribution is the sum of the individual certainties. (For the intuition of this, compare the expression "the whole is (or is not) greater than the sum of its parts". In addition, consider that the knowledge of the posterior comes from a combination of the knowledge of the prior and likelihood, so it makes sense that we are more certain of it than of either of its components.)

The above formula reveals why it is more convenient to do Bayesian analysis of conjugate priors for the normal distribution in terms of the precision. The posterior precision is simply the sum of the prior and likelihood precisions, and the posterior mean is computed through a precision-weighted average, as described above. The same formulas can be written in terms of variance by reciprocating all the precisions, yielding the more ugly formulas

σ 0 2 ′ = 1 n σ 2 + 1 σ 0 2 μ 0 ′ = n x ¯ σ 2 + μ 0 σ 0 2 n σ 2 + 1 σ 0 2 x ¯ = 1 n ∑ i = 1 n x i {\displaystyle {\begin{aligned}{\sigma _{0}^{2}}'&={\frac {1}{{\frac {n}{\sigma ^{2}}}+{\frac {1}{\sigma _{0}^{2}}}}}\\\mu _{0}'&={\frac {{\frac {n{\bar {x}}}{\sigma ^{2}}}+{\frac {\mu _{0}}{\sigma _{0}^{2}}}}{{\frac {n}{\sigma ^{2}}}+{\frac {1}{\sigma _{0}^{2}}}}}\\{\bar {x}}&={\frac {1}{n}}\sum _{i=1}^{n}x_{i}\end{aligned}}}