Bayesian inference of normal distribution

64 Views Asked by At

Find your posterior distribution for $\mu$ when observing $n$ data with sample mean $\bar{x}$ from $X \sim^{iid} N(\mu, 1)$, with a prior distribution for $\mu \sim N(m,v)$.

What I have tried

$$\begin{align} \pi(\mu) &\propto e^{-\frac{(\mu-m)^2}{2v}} \\ L(x, \mu)&\propto e^{-\frac{n(\mu-\bar{x})^2}{2}} \end{align}$$

To find the posterior distribution I use

$$\pi(\mu,x) = \frac{\pi(\mu)L(x, \mu)}{\pi(x)}$$

Where $$\pi(x) = \int_{\mu'}L(x, \mu')\pi(\mu')d\mu'$$

Such that $$\begin{align}\pi(\mu)\cdot L(x, \mu) &= e^{\frac{-nv(\mu-\bar{x})^2-(\mu-m)^2}{2v}} \\ &= e^{\frac{-nv\mu^2+2nv\mu\bar{x}-nv\bar{x}^2-\mu^2+2\mu m-m^2}{2v}} \\ &= e^{\frac{-\mu^2(nv+1) +2\mu(nv\bar{x}+\mu m)-(nv\bar{x}^2+m^2)}{2v}}\end{align}$$

This gives me the following: $$\frac{e^{\frac{-\mu^2(nv+1) +2\mu(nv\bar{x}+\mu m)-(nv\bar{x}^2+m^2)}{2v}}}{\int_{0}^{\infty}e^{\frac{-\mu^2(nv+1) +2\mu(nv\bar{x}+\mu m)-(nv\bar{x}^2+m^2)}{2v}}d\mu}$$

I'm uncertain as to whether this is the correct approach - how do I proceed from here?

1

There are 1 best solutions below

0
On BEST ANSWER

When dealing with posterior, the only thing matters is the parameter, $\mu$ in this case, and the rest can be treated as constant.

$$ p(\mu) \propto exp( - (\mu - m)^2/2\nu) \prod exp(-(x_i-\mu)^2/2) \\ \propto exp\big(-\frac{(\mu^2 -2m\mu)}{2\nu} - \frac{n\mu^2 - 2\sum x_i \mu}{2}\big)\\ =exp\big(-\frac{(1+n\nu)\mu^2 -2(m + n \bar{x} \nu)\mu }{2\nu}\big) \\ =exp \big(- \frac{\mu^2 - 2 (m + n\bar{x}\nu)/(1+n\nu) \mu }{2\nu/(1+n\nu)}\big) $$ which implies

$$ \mu \sim N\big((m+n\bar{x}\nu)/(1+n\nu), \nu/(1+n\nu)\big) $$