Expected values involving two random variables have similar properties to those of functions of a single random variable. In particular,
Properties of expected values
For any functions of two random variables, \(g(X,Y)\) and \(h(X,Y)\), and constants \(a\) and \(b\),
(Proved in full version)
Conditional expected values are simply defined as expected values for the conditional distributions of \(X\) given \(Y=y\) or of \(Y\) given \(X=x\).
Definition
If \(X\) and \(Y\) are discrete random variables, the conditional expected value of \(g(X,Y)\), given that \(X = x\) is
\[ E[g(X,Y) \mid X = x] \;\;=\;\; \sum_{\text{all }y} g(x,y) p_{Y \mid X=x}(y) \]where \(p_{Y \mid X=x}(y)\) is the conditional probability function of \(Y\) given \(X=x\).
If \(X\) and \(Y\) are continuous random variables, the definition is similar with the conditional probability density function replacing \(p_{Y \mid X=x}(y)\) and integration replacing summation.
Note here that \(E[g(X,Y) \mid X = x]\) is a function of \(x\). In a similar way, \(E[g(X,Y) \mid Y = y]\) is a function of \(y\).
The following result sometimes provides an easy way to find unconditional expected values.
Unconditional expected values from conditional ones
For any functions of two random variables, \(g(X,Y)\),
\[ E\big[g(X,Y)\big] \;\;=\;\; E \Big[E\big[g(X,Y) \mid X\big] \Big] \]where the outer expectation is over the marginal distribution of \(X\) and the inner expectation is over the conditional distribution of \(Y\) given \(X\).
(Proved in full version)