        \problemdata       % Takes 5 *mandatory* arguments
        {expect0}             % latex-friendly label for the prob.
        {expectation}  % The topic(s) of the problem content.
        {}               % Source (if known)
        {S02 cp11f-4} % Usage (list ones you are aware of).
        {Ashish, S02}        % Last revision info (author, date).



\begin{problem}
Theorem: If X and Y are two random variables, such that
$$
\forall x\neq 0, y\neq 0,~~\prob{X=x\wedge Y=y}=\prob{X=x}\prob{Y=y}
$$
then
$$
\expect{XY}=\expect{X}\expect{Y}
$$

\begin{proof}
$$
\forall x\neq 0, y\neq 0,~~\prob{X=x\wedge Y=y}=\prob{X=x}\prob{Y=y}
$$
implies that
\begin{eqnarray}
\expect{XY}&=&\sum_{x, y} xy\prob{X=x \wedge Y=y}\\
&=&\sum_{x, y\neq 0} xy\prob{X=x \wedge Y=y}\\
&=&\sum_{x, y\neq 0} xy\prob{X=x}\prob{Y=y}\\
&=&\sum_{x, y\neq 0} x\prob{X=x}y\prob{Y=y}\label{frombug}\\
&=&\sum_{x\neq 0}\sum_{y\neq 0}x\prob{X=x}y\prob{Y=y}\\
&=&\sum_{x\neq 0} x\prob{X=x} \sum_{y\neq 0} y\prob{Y=y}\label{tobug} \\
&=&\sum_{x\neq 0} x\prob{X=x} \expect{Y} \\
&=&\expect{Y}\sum_{x\neq 0} x\prob{X=x}  \\
&=&\expect{Y}\expect{X}
\end{eqnarray}
\end{proof}

\begin{problemparts}
\problempart For each line in the proof, briefy justify its correctness. 

\solution{
(1) - definition of expectation.
(2) - term is zero when $x$ or $y$ is zero.
(3) - by hypothesis.
(4) - multiplication is commutative.
(5) - reordering sums.
(6) - factorization.
(7) - definition of expectation.
(8) - factorization.
(9) - definition of expectation.
}

\problempart 
One of the TAs thought that the theorem was incorrect and proposed the
following counter-example (see below). What is wrong with this
counter-example?

\begin{eqnarray*}
X&=&\left\{
\begin{array}{ll}
0&\textrm{  with probability }1/2\\
1&\textrm{  with probability }1/2
\end{array}\right.\\
Y&=&1-X
\end{eqnarray*}
Then $\expect{X}=\expect{Y}=1/2$, but $\expect{XY}=\expect{0}=0$.

\solution{At $x=1$ and $y=1$, $\prob{X=x\wedge Y=y} = 0$ while
$\prob{X=x}\prob{Y=y} = \frac{1}{2}\cdot\frac{1}{2} = \frac{1}{4}$.  The
TA's example therefore does not fit the requirements for the random
variables $X,Y$.}
\end{problemparts} 
\end{problem}
