$E[P(X|Y)]=\sum_iP(X|Y=i)P(Y=i)$?

34 Views Asked by At

I found an equality, but I don't see why it is true. I hope you can help me see it.

Why is it true that $E[P(X|Y)]=\sum_iP(X|Y=i)P(Y=i)$?

Thank you!

1

There are 1 best solutions below

0
On

$P(X|Y)$ is a function of $Y$, and we could write $f(Y) = P(X|Y)$ for some function $f$. Then $$ \mathbb{E}[P(X|Y)] = \mathbb{E}(g(Y)) = \sum_{y} g(y)\mathbb{P}(Y=y) = \sum_{y} P(X|Y=y)\mathbb{P}(Y=y) $$