# Bayesian inference for both mean and variance [duplicate]

Let $$x_1,...,x_k$$ distributed from $$\mathcal{N}(\mu,\ 1/\tau)\ (i.i.d)$$ and priors on mean and variance are in form: $$\mu|\tau \sim \mathcal{N}(\mu_0,\frac{1}{\tau})$$ $$\tau \sim Ga(\alpha,\beta)$$ Now how calculate posterior distribution? The formal Bayesian inference says $$P(\mu|x)\propto P(\mu)f_{\mu}(x)$$ but here we have distribution $$\mu|\tau$$ so I guess the inference should be based on $$\mu|\tau$$, i.e. $$P(\mu|x,\tau)\propto P(\mu,\tau)f_{\mu,\tau}(x)$$ but I'm not sure about this and how to continue.

You are correct in your reasoning. Your full likelihood, with some abuse of notation, is $$P(x, \mu, \tau| \mu_0, \alpha, \beta) = \prod_{i=1}^{k}f(x_i|\mu,\tau)P(\mu|\mu_0, \tau)P(\tau|\alpha, \beta)$$, so you can get your posterior distributions, \begin{align*} P(\mu|\mu_0, x,\tau) & \propto \prod_{i=1}^{k}f(x_i|\mu,\tau)P(\mu|\tau) \\ P(\tau|x,\alpha, \beta) & \propto \prod_{i=1}^{k}f(x_i|\mu,\tau)P(\mu|\mu_0, \tau)P(\tau|\alpha, \beta). \end{align*}
If you write out the full equations, solve for $$\mu$$ and $$\tau$$ in their respective posteriors, you will get your answer.