# Understand conditional expectation w.r.t. sigma -algebra [duplicate]

When a random variable $$X$$ is discrete, the definition of conditional expectation of $$X$$ with respect to a decomposition $$\mathscr D$$ is $$E[X|\mathscr D] = \sum_{i = 1}^m x_i \sum_{j = 1}^n P(X|\mathscr D_j)I_{D_j}$$ where $$I_{\mathscr D_j}$$ is an indicator function.

When random variable $$X$$ is continuous, The conditional expectation of $$X$$ with respect to a $$\sigma$$-algebra $$\mathscr F$$ is a nonnegative random variable $$\def\E{\mathbf E}\E(X\mid \mathscr F)$$, such that

1. $$\def\E{\mathbf E}\E(X\mid \mathscr F)$$ is $$\mathscr F-measurable$$
2. for all $$A \in \mathscr F\\$$, $$\int_A \def\E{\mathbf E}\E(X\mid \mathscr F)\, dP=\int_A X\, dP$$

I find it is hard to link those two definitions. In discrete case, conditional probability is defined first and we derive conditional expectation based on conditional probability. And it is a similar way as to define conditional expectation w.r.t random variable. But in continuous case, we first state that there exists a unique random variable, and just give it a name as $$\def\E{\mathbf E}\E(X\mid \mathscr F)$$. I wonder why this random variable can be viewed as a conditional expectation in continuous case and its link to discrete case.