# Calculate the covariance between max(X,Y) and min(X,Y)

Let $X$ and $Y$ be independent discrete random variables, each taking values $1$ and $2$ with probability $1/2$ each. How do I calculate the covariance between $max(X,Y)$ and $min(X,Y)$?

-

First, $$\begin{array}{} \mathrm{P}(\max(X,Y)=2)=\frac34\qquad\text{and}\qquad\mathrm{P}(\max(X,Y)=1)=\frac14\\ \mathrm{P}(\min(X,Y)=2)=\frac14\qquad\text{and}\qquad\mathrm{P}(\min(X,Y)=1)=\frac34\\ \end{array}$$ Therefore, $$\mathrm{E}(\max(X,Y))=\frac74\qquad\text{and}\qquad\mathrm{E}(\min(X,Y))=\frac54$$ Furthermore, \begin{align} \mathrm{P}(\max(X,Y)\min(X,Y)=4)=\mathrm{P}(\min(X,Y)=2)&=\frac14\\ \mathrm{P}(\max(X,Y)\min(X,Y)=2)\hphantom{\ =\mathrm{P}(\min(X,Y)=2)}&=\frac12\\ \mathrm{P}(\max(X,Y)\min(X,Y)=1)=\mathrm{P}(\max(X,Y)=1)&=\frac14\\ \end{align} Therefore, $$\mathrm{E}(\max(X,Y)\min(X,Y))=\frac94$$ Thus, \begin{align} &\mathrm{Cov}(\max(X,Y),\min(X,Y))\\ &=\mathrm{E}(\max(X,Y)\min(X,Y))-\mathrm{E}(\max(X,Y))\mathrm{E}(\min(X,Y))\\ &=\frac1{16} \end{align}

-
Shouldn't $9/4-7/4*5/4=1/16$? –  idealistikz Oct 1 '12 at 6:00
@idealistikz: Indeed! Thanks for catching that. –  robjohn Oct 1 '12 at 7:22

Let $W=\min\{X,Y\}$ and $Z=\max\{X,Y\}$; then the desired covariance is $\mathrm{E}[WZ]-\mathrm{E}[W]\mathrm{E}[Z]$. $W=1$ unless $X=Y=2$, so $\mathrm{Pr}(W=1)=\frac34$ and $\mathrm{Pr}(W=2)=\frac14$, and therefore

$$\mathrm{E}[W]=\frac34\cdot1+\frac14\cdot2=\frac54\;.$$

The calculation of $\mathrm{E}[Z]$ is similar. So is that of $\mathrm{E}[WZ]$: just average the four possibilities according to their respective probabilities.

-