4.1 Introduction

Result 4.1.1. If \(X\) and \(Y\) have joint probability function \(f_{X,Y}(x, y)\) and \(g(x, y)\) is a real-valued function, then the expectation of \(g(X, Y)\) is \[ E\bigl (g(X, Y)\bigr ) = \begin {cases} \displaystyle \int \!\!\int g(x, y)f_{X,Y}(x, y)\,dy\,dx , & \text {continuous} , \\[2ex] \displaystyle \sum _x\sum _yg(x, y)f_{X,Y}(x, y) , & \text {discrete,} \end {cases} \] according as \(X\) and \(Y\) are both continuous or both discrete.

Example 4.1.2. An accident occurs at a point \(X\) that is uniformly distributed on a road of length \(L\). At the time of the accident a police patrol car is at a point \(Y\), also uniformly distributed on the road. Assuming that \(X\) and \(Y\) are independent, find the expected distance between the patrol car and the accident.

Solution. By independence, \[ f_{X,Y}(x, y) = f_X(x)f_Y(y) = \frac 1L\cdot \frac 1L = \frac {1}{L^2} , \qquad 0 < x < L , \quad 0 < y < L , \] and we want \(E\bigl (g(X, Y)\bigr )\) with \(g(x, y) = |x - y|\): \[ E\bigl (|X - Y|\bigr ) = \int _0^L\int _0^L|x - y|\,\frac {1}{L^2}\,dx\,dy = \frac {1}{L^2}\int _0^L\int _0^L|x - y|\,dx\,dy . \] Since \(|x - y| = y - x\) for \(x < y\) and \(x - y\) for \(x > y\), the inner integral is \begin {align*} \int _0^L|x - y|\,dx &= \int _0^y(y - x)\,dx + \int _y^L(x - y)\,dx \\ &= \Bigl [xy - \frac {x^2}{2}\Bigr ]_0^y + \Bigl [\frac {x^2}{2} - xy\Bigr ]_y^L \\ &= \Bigl (y^2 - \frac {y^2}{2}\Bigr ) + \Bigl (\frac {L^2}{2} - yL - \frac {y^2}{2} + y^2\Bigr ) = y^2 - yL + \frac {L^2}{2} . \end {align*}

Therefore \begin {align*} E\bigl (|X - Y|\bigr ) &= \frac {1}{L^2}\int _0^L\Bigl (y^2 - yL + \frac {L^2}{2}\Bigr )dy = \frac {1}{L^2}\Bigl [\frac {y^3}{3} - \frac {y^2L}{2} + \frac {yL^2}{2}\Bigr ]_0^L \\ &= \frac {1}{L^2}\Bigl (\frac {L^3}{3} - \frac {L^3}{2} + \frac {L^3}{2}\Bigr ) = \frac L3 . \end {align*}

Theorem 4.1.3 (Boole’s inequality). For any events \(A_1, A_2, \dots , A_k\), \[ P\Bigl (\bigcup _{j=1}^kA_j\Bigr ) \le \sum _{j=1}^kP(A_j) . \]

Proof. Let \[ X_j = \begin {cases} 1 , & \text {if } A_j \text { occurs} , \\ 0 , & \text {otherwise} , \end {cases} \qquad \text {and}\qquad X = \sum _{j=1}^kX_j , \] the number of the events that occur. Then \(E(X_j) = 0 \cdot P(A_j^c) + 1 \cdot P(A_j) = P(A_j)\), so \[ E(X) = \sum _{j=1}^kE(X_j) = \sum _{j=1}^kP(A_j) . \] Now let \(Y = 1\) if \(X \ge 1\) and \(Y = 0\) otherwise, the indicator that at least one event occurs. Then \begin {align*} E(Y) &= 0 \cdot P(X = 0) + 1 \cdot P(X \ge 1) \\ &= P(A_1 \cup A_2 \cup \dots \cup A_k) = P\Bigl (\bigcup _{j=1}^kA_j\Bigr ) . \end {align*}

Since \(Y \le X\) always, \(E(Y) \le E(X)\), which is the inequality. □

Result 4.1.4.

(i)
\(\Cov (aX + b, cY + d) = ac\Cov (X, Y)\).
(ii)
\(\Cov \Bigl (\sum _{i=1}^nX_i, \sum _{j=1}^kY_j\Bigr ) = \sum _{i=1}^n\sum _{j=1}^k\Cov (X_i, Y_j)\).
(iii)
\(\Var \Bigl (\sum _{i=1}^nX_i\Bigr ) = \sum _{i=1}^n\Var (X_i) + 2\sum \sum _{i<j}\Cov (X_i, X_j)\).

Proof. (i) \(aX + b - E(aX + b) = a\bigl (X - E(X)\bigr )\) and \(cY + d - E(cY + d) = c\bigl (Y - E(Y)\bigr )\), so \(\Cov (aX + b, cY + d) = E\bigl [ac(X - E(X))(Y - E(Y))\bigr ] = ac\Cov (X, Y)\).

(ii) Write \(U = \sum _{i=1}^nX_i\) and \(V = \sum _{j=1}^kY_j\), so that \(UV = \sum _i\sum _jX_iY_j\). Using \(\Cov (U, V) = E(UV) - E(U)E(V)\), \begin {align*} \Cov (U, V) &= E\Bigl (\sum _{i=1}^n\sum _{j=1}^kX_iY_j\Bigr ) - E(U)E(V) \\ &= \sum _{i=1}^n\sum _{j=1}^kE(X_iY_j) - \sum _{i=1}^n\sum _{j=1}^kE(X_i)E(Y_j) \\ &= \sum _{i=1}^n\sum _{j=1}^k\bigl \{E(X_iY_j) - E(X_i)E(Y_j)\bigr \} = \sum _{i=1}^n\sum _{j=1}^k\Cov (X_i, Y_j) . \end {align*}

(iii) By (ii) with \(Y_j = X_j\), \[ \Var \Bigl (\sum _{i=1}^nX_i\Bigr ) = \Cov \Bigl (\sum _{i=1}^nX_i, \sum _{j=1}^nX_j\Bigr ) = \sum _{i=1}^n\sum _{j=1}^n\Cov (X_i, X_j) . \] The terms with \(i = j\) are \(\Cov (X_i, X_i) = \Var (X_i)\), and the terms with \(i \ne j\) come in equal pairs, \(\Cov (X_i, X_j) = \Cov (X_j, X_i)\), so \[ \Var \Bigl (\sum _{i=1}^nX_i\Bigr ) = \sum _{i=1}^n\Var (X_i) + 2\sum \sum _{i<j}\Cov (X_i, X_j) . \] □

Definition 4.1.5. Let \(X\) and \(Y\) have joint probability function \(f_{X,Y}(x, y)\). The conditional expectation of \(X\) given \(Y = y\) is \[ E(X \mid Y = y) = \begin {cases} \displaystyle \int x\,f_{X\mid Y}(x \mid y)\,dx , & \text {continuous} , \\[2ex] \displaystyle \sum _xx\,f_{X\mid Y}(x \mid y) , & \text {discrete} , \end {cases} \] where \(f_{X\mid Y}(x \mid y) = f_{X,Y}(x, y)/f_Y(y)\) is the conditional probability function of \(X\) given \(Y = y\).

Note. \(E(X \mid Y = y)\) is a number for each value \(y\). Replacing \(y\) by the random variable \(Y\) gives \(E(X \mid Y)\), which is a function of \(Y\) and so is itself a random variable; its value when \(Y = y\) is \(E(X \mid Y = y)\).

Example 4.1.6. If \(X\) and \(Y\) are independent binomial random variables, each with parameters \((n, p)\), find the conditional expectation of \(Y\) given \(X + Y = k\).

Solution. By Example 1.3.2 (with \(m = n\), and the roles of \(X\) and \(Y\) exchanged), given \(X + Y = k\), \(Y\) has the hypergeometric distribution \[ P(Y = y \mid X + Y = k) = \frac {\binom ny\binom n{k-y}}{\binom {2n}k} , \] so \[ E(Y \mid X + Y = k) = \sum _yy\,\frac {\binom ny\binom n{k-y}}{\binom {2n}k} , \] the mean of a hypergeometric distribution: \(k\) draws from \(2n\) items of which \(n\) are of the kind counted. By the result below this mean is \(k \cdot n/(2n) = k/2\), as symmetry between \(X\) and \(Y\) demands.

Mean of the hypergeometric distribution

Suppose \(n\) balls are selected at random, without replacement, from an urn containing \(N\) balls of which \(m\) are white, and let \(X\) be the number of white balls selected, so that \[ P(X = x) = \frac {\binom mx\binom {N-m}{n-x}}{\binom Nn} , \qquad x = 0, 1, \dots , \min (n, m) . \] Number the white balls \(1, \dots , m\), and let \(X_i = 1\) if the \(i\)th white ball is selected and \(X_i = 0\) otherwise. Then \(X = X_1 + X_2 + \dots + X_m\), and \begin {align*} E(X_i) &= P(\text {the } i\text {th white ball is selected}) = \frac {\binom 11\binom {N-1}{n-1}}{\binom Nn} \\ &= \frac {(N - 1)!\,n!\,(N - n)!}{(n - 1)!\,(N - n)!\,N!} = \frac nN , \end {align*}

so \[ E(X) = \sum _{i=1}^mE(X_i) = \sum _{i=1}^m\frac nN = \frac {mn}N . \]

Questions on this section

Stuck on something here? Ask below and it stays attached to this topic.