Definition 14 (Conditional expectation) Discrete case. Let \(X\) and \(Y\) be jointly distributed discrete random variables. The conditional probability mass function of \(Y\) given \(X = x\) (for values of \(x\) with \(\text{P}(X = x) > 0\)) is:
\[\text{P}(Y = y \mid X = x) \stackrel{\text{def}}{=}\frac{\text{P}(X = x,\, Y = y)}{\text{P}(X = x)}\]
The conditional expectation of \(Y\) given \(X = x\) is:
\[\text{E}{\left[Y \mid X = x\right]} \stackrel{\text{def}}{=}\sum_{y \in \mathcal{R}(Y)} y \cdot\text{P}(Y = y \mid X = x)\]
Continuous case. Let \(X\) and \(Y\) be jointly distributed continuous random variables with joint density \(\text{p}(X = x,\, Y = y)\) and marginal density \(\text{p}(X = x)\). The conditional probability density function of \(Y\) given \(X = x\) (for values of \(x\) with \(\text{p}(X = x) > 0\)) is:
\[\text{p}(Y = y \mid X = x) \stackrel{\text{def}}{=}\frac{\text{p}(X = x,\, Y = y)}{\text{p}(X = x)}\]
The conditional expectation of \(Y\) given \(X = x\) is:
\[\text{E}{\left[Y \mid X = x\right]} \stackrel{\text{def}}{=}\int_{y \in \mathcal{R}(Y)} y \cdot\text{p}(Y = y \mid X = x)\, dy\]
Conditional expectation function. The conditional expectation function \(\text{E}{\left[Y \mid X\right]}\) is the function (and hence random variable) of \(X\) obtained by evaluating \(\text{E}{\left[Y \mid X = x\right]}\) at \(X\); that is, \(\text{E}{\left[Y \mid X\right]} = g(X)\) where \(g(x) \stackrel{\text{def}}{=}\text{E}{\left[Y \mid X = x\right]}\).