# Calculating expected value for product of two indicator variables

I want to know if I am doing it right. Assume $X_i$ and $X_j$ are indicator variables. They take value $1$ with probability $p$ and $0$ with probability $(1-p)$

Then

$E(X_iX_j)=1p * 0(1-p) + 1p*1p +0(1-p)*1p +0(1-p)*0(1-p) = p^2$

Am I right? This should imply that $E[X_iX_j] = E[X_i]E[X_j]$ ?

Thanks

• In general we cannot find $E(X_iX_j)$ just knowing $E(X_i)$ and $E(X_j)$. You have assumed independence in your calculation. Apr 7, 2016 at 0:24
• @AndréNicolas could you pls elaborate on that? Thanks Apr 7, 2016 at 0:28
• One coin is tossed, probability of head $1/2$. Let $X_1=1$ if head, and $0$ otherwise. Let $X_2=1$ if tail, $0$ otherwise. Then $E(X_1)=E(X_2)=1/2$. But $X_1X_2$ is always $0$, so $E(X_1X_2)=0$. Apr 7, 2016 at 0:31

Your calculation assumed that $X_i$ and $X_j$ are independent. For if we look at your second term, it assumes that if $\Pr(X_i=1)=p$ and $\Pr(X_j=1)=p$, then $\Pr((X_i=1)\cap (X_j=1))=p^2$.
It is true that if $U$ and $V$ are any independent random variables such that $E(U)$ and $E(V)$ exist, then $E(UV)=E(U)E(V)$.
However, if we do not have independence, it is perfectly possible that $E(X_iX_j)\ne E(X_i)E(X_j)$, even if $X_i$ and $X_j$ are indicator random variables.
For example, toss a fair coin once. Let $X_1=1$ if we get a head, and $0$ otherwise. Let $X_2=1$ if we get a tail, and $0$ otherwise.
Then $E(X_1)=E(X_2)=\frac{1}{2}$. However, $X_1X_2$ is always $0$, so $E(X_1X_2)=0$. Thus, in this example, $E(X_1X_2)\ne E(X_1)E(X_2)$.