Regarding the formula of using $\text{P}(Y|X)$ to compute $\text{E}[X]$ When reading a presentation on "expectation propagation," I found a strange formula for computing $\text{E}[X]$ from a conditional probability:
$$\text{E}[X] = \frac{\int x P(y_i|x) dx}{\int P(y_i|x) dx}$$
Can someone please explain how this formula was derived? The source is slide 24 in the presentation linked above.
 A: $$\text{E}[X] = \frac{\int x \, P(y_i \mid x) \, dx}{\int P(y_i \mid x) \, dx}$$
is not a general statement, but only a first step in expectation propagation (EP). EP tries to approximate a posterior distribution $P(x \mid \mathcal{D})$ using a given factorization of the joint,
$$P(x) \prod_i P(y_i \mid x).$$
To reduce clutter, the dependency on the data $\mathcal{D} = \{ y_1, ..., y_n \}$ is often dropped in the notation. Instead of a posterior distribution, it might actually be less confusing to just think about approximating any distribution whose unnormalized density is given by
$$\phi_0(x) \prod_i \phi_i(x).$$
The first moment of the true distribution would be
$$\text{E}[X] = \int x \, P(x) \, dx = \frac{\int x \, \phi_0(x) \prod_i \phi_i(x) \, dx}{\int \phi_0(x) \prod_i \phi_i(x) \, dx}.$$
EP works by iteratively refining the distribution with one of the factors and approximating the distribution by only keeping some of the moments.
A: The formula on that slide was a straw man and not intended to make sense.  The point was that moment matching does not make sense on an individual likelihood term in isolation.  This is illustrated further on the next slides.  I have actually seen this bad approach used in papers, so I thought it was worth pointing out.  This is one of those cases where "you had to be there."
