# Expectation E(XY) of two dependent variables

If X and Y are 2 dependent variables, how does their combined expectation look? For example, if flipping a fair coin n times, with X representing the number of heads and Y representing the number of tails. How would I calculate E[XY], and what's the intuition behind it?

• What you need is the joint distribution of $(X,Y)$. Then e.g. in discrete case $\mathbb EXY=\sum_{x,y}xyP(X=x,Y=y)$. If there is a PDF then $\mathbb EXY=\int xyf_X(x,y)dxdy$ (both under condition that the expectation exists, of course). In your example we are dealing with the ultimate counterpart of being independent. – drhab May 20 at 12:44

## 1 Answer

In your example of coin tosses, you actually have $$Y=n-X$$. So $$E[XY]=E[X(n-X)]= nE[X] - E\left[X^2\right]$$.

Since $$X\sim \mathrm{Binomial}(n,p)$$, where $$p$$ is the probability of heads on a single coin toss, you can calculate this by using the formula for $$E[X]$$ and $$E\left[X^2\right]$$ when $$X$$ has such distribution. (You can find the formula for $$E\left[X^2\right]$$ at Calculating the Second Moment of a Binomial Random Variable.)

• What if X and Y are correlated but not mirrors of each other? For example throwing a die, where X is the case that 3 is received and Y is the case that 4 is received – EliT May 20 at 12:36
• You mean $X$ is the number of $3$'s rolled in $n$ rolls and $Y$ similarly for $4$? – Minus One-Twelfth May 20 at 12:39
• X represents the number of 3's, Y the number of 4's yes – EliT May 20 at 12:43
• $\newcommand{\Cov}{\operatorname{Cov}}$In that case, we have $E[XY] = \left(n^2-n\right)\cdot \frac{1}{6}\cdot\frac{1}{6}$. This is a special case of the general fact that if $(X_1,\ldots, X_k)$ has a multinomial distribution with $n$ trials and success probabilities $p_1,\ldots , p_k$, then $E\left[X_i X_j\right] = \left(n^2-n\right)p_i p_j$. See e.g. here for a proof of this, and search up "multinomial distribution" online for more information about this distribution. – Minus One-Twelfth May 20 at 12:46
• (Note in that link, their $r$ is my $n$ above, and their $n$ is my $k$ above. Also $k=6$ for standard dice rolls.) – Minus One-Twelfth May 20 at 12:52