$z\_i=f+a\_i+\epsilon\_i$ ，where $f\sim N(\bar{f},\sigma\_{f}^2)$ ; $a\_i\sim N(\bar{a\_{i}},\sigma\_{a}^2)$; $\epsilon\_i\sim N(0,\sigma\_{\epsilon}^2)$. We can see the signals $\{z\_i\}$ where $i\subseteq {1,2,……,M}$, and note that $f$ is a common term for all signals. The question is we want to know the **Posterior mean** of $a\_i$ for any $i$.


The outcome in that paper is as follows but I don't understand it. I want a more detailed process.


\begin{array}{l}
E\left[a\_{i} \mid\left\{z\_{i}\right\}\_{i=1, \ldots, M}\right] \\
=\bar{a}\_{i}+\frac{\sigma\_{a}^{2}\left(\sigma\_{a}^{2}+\sigma\_{\varepsilon}^{2}+(M-1) \sigma\_{f}^{2}\right)}{\left(\sigma\_{a}^{2}+\sigma\_{\varepsilon}^{2}\right)\left(\sigma\_{a}^{2}+\sigma\_{\varepsilon}^{2}+M \sigma\_{f}^{2}\right)}\left(z\_{i}-\bar{z}\_{i}\right)-\frac{\sigma\_{a}^{2} \sigma\_{f}^{2}}{\left(\sigma\_{a}^{2}+\sigma\_{\varepsilon}^{2}\right)\left(\sigma\_{a}^{2}+\sigma\_{\varepsilon}^{2}+M \sigma\_{f}^{2}\right)} \sum\_{j \neq i}\left(z\_{j}-\bar{z}\_{j}\right)
\end{array}



How does this Bayesian updating work $z_i=f+a_i+\epsilon_i$
$\newcommand{\bR}{\mathbb{R}}
\newcommand{\one}{\mathbf{1}}
\newcommand{\diag}{\textrm{diag}}
\newcommand{\Id}{\textrm{Id}}$
I guess you assume independence of the random variables $f,a,\varepsilon$, which I am going to use.


**General strategy** for Gaussian conditioning in linear models:


Let $a\sim N(\bar{a},Q\_{a})$ on $\bR^{n}$ and $z = Aa+\eta$, where $A\in\bR^{m \times n}$ and $\eta \sim N(\bar{\eta},Q\_{\eta})$ on $\bR^{m}$ is independent of $a$.
Then consider the joint distribution of $a$ and $z$,
$$
\begin{pmatrix}
a\\ z
\end{pmatrix}
\sim
N\left(
\begin{pmatrix}
 \bar{a}\\ A\bar{a}+\bar{\eta}
\end{pmatrix}
,
\begin{pmatrix}
 Q\_{a} & Q\_{a}A^{\top} \\ A Q\_{a} & Q\_{\eta} + A Q\_{a} A^{\top}
\end{pmatrix}
\right)
$$
and apply the Gaussian conditioning formula (see e.g. [here, scroll down to Conditional distributions](https://en.wikipedia.org/wiki/Multivariate_normal_distribution)) to obtain the conditional mean
$$
(\ast)\qquad
\bar{a}^{z}
=
\bar{a} + (Q\_{a}A^{\top}) (Q\_{\eta} + A Q\_{a} A^{\top})^{-1} (z-A\bar{a}-\bar{\eta}).
$$


**Answer to your question:**


Now let us consider your particular case and denote $\one\_{m} = (1,\dots,1)^{\top} \in \bR^{m}$ and a diagonal matrix with the values $s\_{1},\dots,s\_{m}$ on the diagonal by $\diag(s\_{1},\dots,s\_{m})$ and by $\diag(s)$ if all $s\_{j}$ equal $s$.


The first nontrivial step is to identify $\eta$ correctly: $z = A a + \eta$, where $A = \mathrm{Id\_{M}}$ and
$$
\eta
=
\underbrace{(\one \ \Id\_{M})}\_{=: B} \begin{pmatrix}
 f\\
 \varepsilon\_{1}\\
 \vdots\\
 \varepsilon\_{M}
\end{pmatrix}
\sim
N\left(
\bar{f}\one , B \, \diag(\sigma\_{f}^2,\sigma\_{\varepsilon}^{2},\dots,\sigma\_{\varepsilon}^{2}) \, B^{\top}
\right).
$$
(Here we used the fact that $y = Bx$, $x\sim N(\bar{x},Q\_{x})$ implies $y\sim N(B\bar{x},BQ\_{x}B^{\top})$; I can provide details on this if required.)
Then, a simple (but tedious) computation shows that
\begin{align\*}
Q\_{\eta} + AQ\_{a}A^{\top}
&=
\diag(\sigma\_{a}^{2} + \sigma\_{\varepsilon}^{2}) + \sigma\_{f}^{2} \one \one^{\top},
\\
(Q\_{\eta} + AQ\_{a}A^{\top})^{-1}
&=
\frac{\diag(\sigma\_{a}^{2} + \sigma\_{\varepsilon}^{2} + M \sigma\_{f}^{2}) - \sigma\_{f}^{2} \one \one^{\top}}{(\sigma\_{a}^{2} + \sigma\_{\varepsilon}^{2})(\sigma\_{a}^{2} + \sigma\_{\varepsilon}^{2} + M \sigma\_{f}^{2})}
\end{align\*}
Note that finding the inverse might be hard, but showing that its the inverse, once you have it, is easy (but tedious): Simply multiply the two matrices above to obtain $\Id\_{M}$.


If you plug this into $(\ast)$ and write it out componentwise you obtain the desired result.


Hope this helps. If you have any questions, don't hesitate to ask in the comments.


**Remarks:**


* $(\ast)$ holds similarly if $\bR^{m}$ and $\bR^{n}$ are replaced by arbitrary separable Hilbert space (possibly infinite-dimensional). In this case replace "transpose" $A^{\top}$ by "adjoint" $A^{\ast}$.
* There is also a formula for the conditional covariance matrix/covariance operator, which, somewhat surprisingly, does not dependent of $z$ (a particular property of Gaussian conditioning):
$$
Q\_{a}^{z}
=
Q\_{a} - Q\_{a}A^{\top} (Q\_{\eta} + AQ\_{a}A^{\top})^{-1} A Q\_{a}.
$$
$a|z \sim N(\bar{a}^{z},Q\_{a}^{z})$ has again a normal distribution.


