# Does covariance equal to zero implies independence for binary random variables?

If $X$ and $Y$ are two random variables that can only take two possible states, how can I show that $Cov(X,Y) = 0$ implies independence? This kind of goes against what I learned back in the day that $Cov(X,Y) = 0$ does not imply independence...

The hint says to start with $1$ and $0$ as the possible states and generalize from there. And I can do that and show $E(XY) = E(X)E(Y)$, but this doesn't imply independence???

Kind of confused how to do this mathematically I guess.

• It is not true in general as your question's heading suggests.. Jan 28, 2017 at 23:50
• The statement that you are trying to prove is indeed true. If $X$ and $Y$ are Bernoulli random variables wot parameters $p_1$ and $p_2$ respectively, then $E[X]=p_1$ and $E[Y]=p_2$. So, $\operatorname{cov}(X,Y)=E[XY]-E[X]E[Y]$ equals $0$ only if $E[XY]=P\{X=1,Y=1\}$ equals $p_1p_2=P\{X=1\}P\{Y=1\}$ showing that $\{X=1\}$ and $\{Y=1\}$ are independent events. It is a standard result that if $A$ and $B$ are a pair of independent events, then so are $A,B^c$, and $A^c,B$, and $A^c,B^c$ independent events, i.e. $X$ and $Y$ are independent random variables. Now generalize. Jan 29, 2017 at 0:06

For binary variables their expected value equals the probability that they are equal to one. Therefore,

$$E(XY) = P(XY = 1) = P(X=1 \cap Y=1) \\ E(X) = P(X=1) \\ E(Y) = P(Y=1) \\$$

If the two have zero covariance this means $E(XY) = E(X)E(Y)$, which means

$$P(X=1 \cap Y=1) = P(X=1) \cdot P(Y=1)$$

It is trivial to see all other joint probabilities multiply as well, using the basic rules about independent events (i.e. if $A$ and $B$ are independent then their complements are independent, etc.), which means the joint mass function factorizes, which is the definition of two random variables being independent.

• Concise and elegant. Classy! +1 =D Feb 3, 2017 at 22:14

Both correlation and covariance measure linear association between two given variables and it has no obligation to detect any other form of association else.

So those two variables might be associated in several other non-linear ways and covariance (and, therefore, correlation) could not distinguish from independent case.

As a very didactic, artificial and non realistic example, one can consider $X$ such that $P(X=x)=1/3$ for $x=−1,0,1$ and also consider $Y=X^2$. Notice that they are not only associated, but one is a function of the other. Nonetheless, their covariance is 0, for their association is orthogonal to the association that covariance can detect.

EDIT

Indeed, as indicated by @whuber, the above original answer was actually a comment on how the assertion is not universally true if both variables were not necessarily dichotomous. My bad!

So let's math up. (The local equivalent of Barney Stinson's "Suit up!")

### Particular Case

If both $X$ and $Y$ were dichotomous, then you can assume, without loss of generality, that both assume only the values $0$ and $1$ with arbitrary probabilities $p$, $q$ and $r$ given by \begin{align*} P(X=1) = p \in [0,1] \\ P(Y=1) = q \in [0,1] \\ P(X=1,Y=1) = r \in [0,1], \end{align*} which characterize completely the joint distribution of $X$ and $Y$. Taking on @DilipSarwate's hint, notice that those three values are enough to determine the joint distribution of $(X,Y)$, since \begin{align*} P(X=0,Y=1) &= P(Y=1) - P(X=1,Y=1) = q - r\\ P(X=1,Y=0) &= P(X=1) - P(X=1,Y=1) = p - r\\ P(X=0,Y=0) &= 1 - P(X=0,Y=1) - P(X=1,Y=0) - P(X=1,Y=1) \\ &= 1 - (q - r) - (p - r) - r = 1 - p - q - r. \end{align*} (On a side note, of course $r$ is bound to respect both $p-r\in[0,1]$, $q-r\in[0,1]$ and $1-p-q-r\in[0,1]$ beyond $r\in[0,1]$, which is to say $r\in[0,\min(p,q,1-p-q)]$.)

Notice that $r = P(X=1,Y=1)$ might be equal to the product $p\cdot q = P(X=1) P(Y=1)$, which would render $X$ and $Y$ independent, since \begin{align*} P(X=0,Y=0) &= 1 - p - q - pq = (1-p)(1-q) = P(X=0)P(Y=0)\\ P(X=1,Y=0) &= p - pq = p(1-q) = P(X=1)P(Y=0)\\ P(X=0,Y=1) &= q - pq = (1-p)q = P(X=0)P(Y=1). \end{align*}

Yes, $r$ might be equal to $pq$, BUT it can be different, as long as it respects the boundaries above.

Well, from the above joint distribution, we would have \begin{align*} E(X) &= 0\cdot P(X=0) + 1\cdot P(X=1) = P(X=1) = p \\ E(Y) &= 0\cdot P(Y=0) + 1\cdot P(Y=1) = P(Y=1) = q \\ E(XY) &= 0\cdot P(XY=0) + 1\cdot P(XY=1) \\ &= P(XY=1) = P(X=1,Y=1) = r\\ Cov(X,Y) &= E(XY) - E(X)E(Y) = r - pq \end{align*}

Now, notice then that $X$ and $Y$ are independent if and only if $Cov(X,Y)=0$. Indeed, if $X$ and $Y$ are independent, then $P(X=1,Y=1)=P(X=1)P(Y=1)$, which is to say $r=pq$. Therefore, $Cov(X,Y)=r-pq=0$; and, on the other hand, if $Cov(X,Y)=0$, then $r-pq=0$, which is to say $r=pq$. Therefore, $X$ and $Y$ are independent.

### General Case

About the without loss of generality clause above, if $X$ and $Y$ were distributed otherwise, let's say, for $a<b$ and $c<d$, \begin{align*} P(X=b)=p \\ P(Y=d)=q \\ P(X=b, Y=d)=r \end{align*} then $X'$ and $Y'$ given by $$X'=\frac{X-a}{b-a} \qquad \text{and} \qquad Y'=\frac{Y-c}{d-c}$$ would be distributed just as characterized above, since $$X=a \Leftrightarrow X'=0, \quad X=b \Leftrightarrow X'=1, \quad Y=c \Leftrightarrow Y'=0 \quad \text{and} \quad Y=d \Leftrightarrow Y'=1.$$ So $X$ and $Y$ are independent if and only if $X'$ and $Y'$ are independent.

Also, we would have \begin{align*} E(X') &= E\left(\frac{X-a}{b-a}\right) = \frac{E(X)-a}{b-a} \\ E(Y') &= E\left(\frac{Y-c}{d-c}\right) = \frac{E(Y)-c}{d-c} \\ E(X'Y') &= E\left(\frac{X-a}{b-a} \frac{Y-c}{d-c}\right) = \frac{E[(X-a)(Y-c)]}{(b-a)(d-c)} \\ &= \frac{E(XY-Xc-aY+ac)}{(b-a)(d-c)} = \frac{E(XY)-cE(X)-aE(Y)+ac}{(b-a)(d-c)} \\ Cov(X',Y') &= E(X'Y')-E(X')E(Y') \\ &= \frac{E(XY)-cE(X)-aE(Y)+ac}{(b-a)(d-c)} - \frac{E(X)-a}{b-a} \frac{E(Y)-c}{d-c} \\ &= \frac{[E(XY)-cE(X)-aE(Y)+ac] - [E(X)-a] [E(Y)-c]}{(b-a)(d-c)}\\ &= \frac{[E(XY)-cE(X)-aE(Y)+ac] - [E(X)E(Y)-cE(X)-aE(Y)+ac]}{(b-a)(d-c)}\\ &= \frac{E(XY)-E(X)E(Y)}{(b-a)(d-c)} = \frac{1}{(b-a)(d-c)} Cov(X,Y). \end{align*} So $Cov(X,Y)=0$ if and only $Cov(X',Y')=0$.

=D

• I recycled that answer from this post. Jan 29, 2017 at 5:51
• Verbatim cut and paste from your other post. Love it. +1 Jan 29, 2017 at 6:04
– whuber
Jan 29, 2017 at 16:22
• How is thus an answer to the question asked? Feb 2, 2017 at 5:18
• Your edits still don't answer the question, at least not at the level the question is asked. You write "Notice that $r~\ldots$ not necessarily equal to the product $pq$. That exceptional situation corresponds to the case of independence between $X$ and $Y$." which is a perfectly true statement but only for the cognoscenti because for the hoi polloi, independence requires not just that $$P(X=1,Y=1)=P(X=1)P(Y=1)\tag 1$$ but also $$P(X=u,Y=v)=P(X=u)P(Y=v),~u.v\in\{0,1\}.\tag 2$$ Yes, $(1) \implies(2)$ as the cognoscenti know; for lesser mortals, a proof that $(1) \implies (2)$ is helpful. Feb 4, 2017 at 1:51

IN GENERAL:

The criterion for independence is $F(x,y) = F_X(x)F_Y(y)$. Or $$f_{X,Y}(x,y)=f_X(x)\,f_Y(y)\tag 1$$

"If two variables are independent, their covariance is $0.$ But, having a covariance of $0$ does not imply the variables are independent."

This is nicely explained by Macro here, and in the Wikipedia entry for independence.

$\text {independence} \Rightarrow \text{zero cov}$, yet

$\text{zero cov}\nRightarrow \text{independence}.$

Great example: $X \sim N(0,1)$, and $Y= X^2.$ Covariance is zero (and $\mathbb E(XY)=0$, which is the criterion for orthogonality), yet they are dependent. Credit goes to this post.

IN PARTICULAR (OP problem):

These are Bernoulli rv's, $X$ and $Y$ with probability of success $\Pr(X=1)$, and $\Pr(Y=1)$.

\begin{align}\mathrm{cov}(X,Y)&=\mathrm E[XY] - \mathrm E[X]\,\mathrm E[Y]\\[2ex] &\underset{*}{=} \Pr(X=1 \cap Y=1) - \Pr(X=1)\, \Pr(Y=1)\\[2ex] &\implies \Pr(X=1 , Y=1) = \Pr (X=1)\,\Pr(Y=1). \end{align}

This is equivalent to the condition for independence in Eq. $(1).$

$(*)$:

$$\mathrm E[XY]\quad \underset{**}{=} \quad \displaystyle \sum_{\text{domain X, Y}} \Pr(X=x\cap Y=y)\, x\,y \underset{\neq\,0\text{ iff } x \times y\neq 0}= \Pr(X=1 \cap Y=1).$$

$(**)$: by LOTUS.

As pointed out below, the argument is incomplete without what Dilip Sarwate had pointed out in his comments shortly after the OP appeared. After searching around, I found this proof of the missing part here:

If events $A$ and $B$ are independent, then events $A^c$ and $B$ are independent, and events $A^c$ and $B^c$ are also independent.

Proof By definition,

$A$ and $B$ are independent $\iff P(A\cap B) = P(A)P(B).$

But $B=(A\cap B) + ( A^c \cup B)$, so $P(B)= P(A\cap B) + P(A^c \cup B)$, which yields:

$\small P(A^c \cap B) = P(B) - P(A\cap B) = P(B) - P(A)\,P(B) = P(B) \left[1 - P(A)\right] = P(B)\,P( A^c).$

Repeat the argument for the events $A^c$ and $B^c,$ this time starting from the statement that $A^c$ and $B$ are independent and taking the complement of $B.$

Similarly. $A$ and $B^c$ are independent events.

So, we have shown already that $$\Pr(X=1 , Y=1) = \Pr (X=1)\,\Pr(Y=1)$$ and the above shows that this implies that $$\Pr(X=i , Y=j) = \Pr (X=i)\,\Pr(Y=j), ~~i, j \in \{0,1\}$$ that is, the joint pmf factors into the product of marginal pmfs everywhere, not just at $(1,1)$. Hence, uncorrelated Bernoulli random variables $X$ and $Y$ are also independent random variables.

• Actually that's not an equivalent condition to Eq (1). All you showed was that $f_{X,Y}(1,1) = f_{X}(1) f_{Y}(1)$ Jan 29, 2017 at 6:08
• Please consider replacing that image with your own equations, preferably ones that don't use overbars to denote complements. The overbars in the image are very hard to see. Feb 3, 2017 at 4:05
• @DilipSarwate No problem. Is it better, now? Feb 3, 2017 at 4:43
• Thanks. Also, note that strictly speaking, you also need to show that $A$ and $B^c$ are independent events since the factorization of the joint pdf into the product of the marginal pmts must hold at all four points. Perhaps adding the sentence "Similarly. $A$ and $B^c$ are independent events" right after the proof that $A^c$ and $B$ are independent events will work. Feb 3, 2017 at 5:03
• @DilipSarwate Thank you very much for your help getting it right. The proof as it was before all the editing seemed self-explanatory, because of all the inherent symmetry, but it clearly couldn't be taken for granted. I am very appreciative of your assistance. Feb 3, 2017 at 5:10