# Joint and Marginal Posterior PDFs (Bayesian)

I am given the joint posterior pdf:

$$f(\mu,\sigma^2\mid\mathbf x) \propto (\sigma^2)^{-n/2-1}\exp{\left(-\frac{1}{2}\frac{\sum^n_{i=1}(x_i-\mu)^2}{\sigma^2}\right)}$$

I understand that marginal posterior pdfs can be obtained by integrating and removing out the other variable. With the given equation:

$$\sum^n_{i=1}(x_i-\mu)^2 = \sum^n_{i=1}(x_i-\bar x)+n(\mu-\bar x)^2$$

I tried to show that the marginal pdf $$f(\sigma^2|\mathbf x)$$ is proportional to

$$(\sigma^2)^{-n/2-1/2}\exp{\left(-\frac{1}{2}\frac{\sum^n_{i=1}(x_i-\bar x)^2}{\sigma^2}\right)}$$

however by substituting the given equation to the joint posterior pdf and integrating it with respects to $$\mu$$, I was still not able to obtain the correct marginal pdf $$f(\sigma^2\mid\mathbf x)$$.

Can anyone help me out please? Thank you.