# Discrete random variables $X, Y$ with 2 values are independent iff $\operatorname{Cor}(X,Y)=0$.

Let $X$ and $Y$ be two discrete random variables: $$P(X=x_1)=p_1,\quad P(X=x_2)=1-p_1$$ $$P(Y=y_1)=p_2,\quad P(Y=y_2)=1-p_2$$ How to show that $X$ and $Y$ are independent if and only if the correlation coefficient between $X$ and $Y$ is zero?

One direction is easy because if $X$ and $Y$ are independent, then $$\operatorname{Cov}(X,Y)=E(XY)-E(X)E(Y)=E(X)E(Y)-E(X)E(Y)=0.$$ But I am having trouble proving the other direction. I get $$\sum_{i,j=1}^2x_iy_jP(X=x_i,Y=y_j)=x_1y_2p_1p_2+x_1y_2p_1(1-p_2)+x_2y_1(1-p_1)p_2+x_2y_2(1-p_1)(1-p_2),$$ but I don't know why this would imply that $X$ and $Y$ are independent.

• If $P(X=x_1, Y=y_1)=q$ then $P(X=x_1, Y=y_2)= p_1-q$, and $P(X=x_2, Y=y_1) = p_2-q$ and $P(X=x_2, Y=y_2) = 1-p_1-p_2+q$
• So you can calculate $E[XY]$. You can also calculate $E[X]E[Y]$
• Since the covariance is zero these must be equal, so you can solve for $q$ in terms of $p_1$ and $p_2$.
• If $q=p_1p_2$ then $P(X=x_1, Y=y_1)=P(X=x_1)P(Y=y_1)$ and more generally $P(X=x_i, Y=y_j)=P(X=x_i)P(Y=y_j)$. So $X$ and $Y$ are independent.