I'm following this tutorial on variational inference [1] and I wanted to try to derive the analytical form of the posterior distribution. Given the following random variables:
$ |∼(,1)$
$ |,∼(,0.75)$
The problem is to calculate the distribution of:
$|,$
Given measurement = 9.5 and guess = 8.5, the analytical result would be Normal(9.14,0.6).
My first thought was to apply Bayes Law like so:
$p(weight | measurement, guess) \sim p(measurement | weight, guess) * p(weight | guess) $
But I was unable to arrive at the correct answer. I'd appreciate any help :)
Thanks!
EDIT: I copied the wrong values :)
You are on the right track. The detailed derivation is in section 3.4 here. Let's denote the guess distribution as $N(\mu_{g}, \sigma_{g})$, and the measurement distribution as $N(\mu_{m}, \sigma_{m})$. The posterior mean is $$\frac{\sigma_{g}^2\mu_{g} + n_m\sigma_{m}^2\mu_{m}}{\sigma_{g}^2 + n_m \sigma_m^2} $$ where $n_m$ is the sample size of the measurement. The posterior variance is $$\frac{\sigma_g^2\sigma_m^2}{\sigma_g^2 + n_m \sigma_m^2}$$.
Note that in the Pyro tutorial, they use standard deviation instead of variance, so you need to square $\sigma$.