# How to show that $\mu$ is normally distributed

Suppose we have:

$$p(\mu \mid \sigma, \boldsymbol{w}, \boldsymbol{y}) \propto \exp\left[-\frac{1}{2\sigma^2}\sum_{t=1}^T\left(\frac{(y_t-\mu)^2}{w_t^2}\right) \right]$$

where $\boldsymbol{w} = (w_1, w_2, \cdots, w_t)$ and $\boldsymbol{y} = (y_1, y_2, \cdots, y_t)$

How do I show that:

$$p(\mu \mid \sigma, \boldsymbol{w}, \boldsymbol{y}) \propto \exp\left[-\frac{\sum_{t=1}^T(1/w_t^2)}{2\sigma^2}\left(\mu-\frac{\sum_{t=1}^T(y_t/w_t^2)}{\sum_{t=1}^T(1/w_t^2)} \right)^2 \right]$$

so that $\displaystyle \mu \mid \sigma, \boldsymbol{w}, \boldsymbol{y} \sim N\left(\frac{\sum_{t=1}^T(y_t/w_t^2)}{\sum_{t=1}^T(1/w_t^2)}, \frac{\sigma^2}{\sum_{t=1}^T(1/w_t^2)} \right)$?

Just can't seem to get the algebra right...

Hint: Like every quadratic polynomial in $\mu$, the sum in the exponential is $$\sum_{t}\frac{(y_t-\mu)^2}{w_t^2}=A_T\mu^2-2B_T\mu+C_T=A_T\left(\mu-\frac{B_T}{A_T}\right)^2+C_T-\frac{B_T^2}{A_T},$$ hence it suffices to identify the coefficients $A_T$, $B_T$ and $C_T$. Note that $A_T$ is the leading coefficient of the polynomial in $\mu$ in the LHS hence $$A_T=\sum_{t}\frac{1}{w_t^2}.$$ Likewise, $C_T$ corresponds to the value of the LHS when $\mu=0$ hence $$C_T=\sum_{t}\frac{y_t^2}{w_t^2}.$$ Finally $(-2B_T)$ is the value of the derivative of the LHS with respect to $\mu$ at $\mu=0$ hence $$B=\sum_{t}\frac{y_t}{w_t^2}.$$ Finally, $$p(\mu\mid\sigma,y,w)\propto\exp\left(-\frac{A_T}{2\sigma^2}\left(\mu-\frac{B_T}{A_T}\right)^2\right).$$