Conditional Expectation
Conditional expectation is just expectation computed with conditional probability:
For discrete:
\[ \mathbb{E}[X\mid Y] = \sum_{x} x \cdot p_{X\mid Y}(x\mid y) dx \]
For continuous:
\[ \mathbb{E}[X\mid Y] = \int_{-\infty}^{\infty} x \cdot f_{X\mid Y}(x\mid y) dx \]
- Law of total expectation allows us to decompose expectation into smaller expectations:
\[ \mathbb{E}[X] = \sum_y\mathbb{E}[X\mid Y= y]p_Y(y)\\ \mathbb{E}[X] = \int_{-\infty}^{\infty}\mathbb{E}[X\mid Y= y]f_Y(y) dy\\ \text{compact form:}\\ \mathbb{E}[X] = \mathbb{E}_Y[\mathbb{E}_{X|Y}[X|Y]] \]
Here the subscripts on the expectation tell you what distribution to use.