# Posterior distribution of a multi parameter model

Suppose I have a sample of observations $y = (y_1,y_2, ... ,y_n)$ is drawn from a normal distribution $N(\mu,\sigma^2)$. We are assuming a non-informative prior on $(\mu,\log\sigma)$ i.e; $f(\mu,\sigma^2) \propto 1/\sigma^2$. We have to find the posterior distribution $f(\mu,\sigma^2|y)$.

Let's work it out. \begin{align} f(\mu,\sigma^2|y) &\propto f(\mu,\sigma^2) f(y|\mu,\sigma^2) \\ f(\mu,\sigma^2|y) &\propto \sigma^{-2} (2\pi)^{-n/2} \sigma^{-n} \exp\bigg(\frac {-1}{2\sigma^2} \sum_{i}(y_i-\mu)^2\bigg) \end{align} The next steps shown by my professor, which I do not understand are

$$f(\mu,\sigma^2|y) \propto \sigma^{-n-2} \exp\bigg(\frac {-1}{2\sigma^2} [\sum_i(y_i-\bar y)^2 + n(\bar y - \mu)^2]\bigg)$$

and he quoted $\because$ Sum of deviations from the mean is zero.

$$f(\mu,\sigma^2|y) \propto \sigma^{-n-2} \exp\bigg(\frac {-1}{2\sigma^2} [(n-1)s^2 + n(\bar y-\mu)^2]\bigg)$$

where $s^2$ is an unbiased estimator of ${\rm Var}(y)$

Kindly help me understanding the last two steps.

• Try to rewrite the sum like this $\sum_i((y_i - \bar{y}) - (\mu -\bar{y}))^2$ – Łukasz Grad Feb 4 '17 at 18:38
• Please check stats.stackexchange.com/tags/self-study/info and add [self-study] tag. – Tim Feb 4 '17 at 18:59
• No, but in the class, my professor wrote the same which I have written. @ŁukaszGrad – Ashu Prakash Feb 5 '17 at 18:15
• @AshuPrakash He ommited this step. Note that these sums are equal. Try to calculate $\sum_i(y_i - \mu)^2 = \sum_i((y_i - \bar{y})-(\mu - \bar{y}))^2 = \dots$ – Łukasz Grad Feb 5 '17 at 18:38