We roll a die $10$ times. Let $X$ denote the number of odd numbers and $Y$ denote the number of primes. Find $\operatorname{Cov}(X,\ Y)$.
My answer:
$$\operatorname{Cov}(X,\ Y)=E[XY]-E[X]E[Y]=3-5*4=3-20=-17$$
Does that look correct?
We roll a die $10$ times. Let $X$ denote the number of odd numbers and $Y$ denote the number of primes. Find $\operatorname{Cov}(X,\ Y)$.
My answer:
$$\operatorname{Cov}(X,\ Y)=E[XY]-E[X]E[Y]=3-5*4=3-20=-17$$
Does that look correct?
On
The odds are $\{1,3,5\}$, the primes are $\{2,3,5\}$; so
$$\operatorname{E}[X]=\operatorname{E}[Y]=10\cdot\frac{1}{2}=5$$
To find $\operatorname{E}[XY]$ we use indicator variables
$$X=\sum_{i=1}^{10}I_i$$ $$Y=\sum_{j=1}^{10}J_j$$
$$\operatorname{E}[XY]=\operatorname{E}[\sum_{i=1}^{10}I_i\sum_{j=1}^{10}J_j]= \sum_{i=1}^{10}\operatorname{E}[I_iJ_i]+\sum_{i\neq j}^{10}\operatorname{E}[I_iJ_j]$$
Since the different rolls are independent, for $i \neq j$ we have
$$\operatorname{E}[I_iJ_j]=\operatorname{E}[I_i]\operatorname{E}[J_j]=\frac{1}{2}\cdot \frac{1}{2} = \frac{1}{4}$$
$I_iJ_i$ is equal to $1$ if the roll gives $3$ or $5$, so
$$\operatorname{E}[I_iJ_i]=\frac{2}{6} = \frac{1}{3}$$
Putting it all together
$$\operatorname{cov}(X,Y)=10\cdot \frac{1}{3}+90\cdot\frac{1}{4}-5\cdot 5=\frac{10}{12}=\frac{5}{6}$$
No, it does not look right. Note that $\frac{\text{Cov}(X,Y)}{\sqrt{\text{Var}(X)\text{Var}(Y)}}$ should be between $-1$ and $1$. Since the two variances are $2.5$ and $2.4$, the covariance cannot be $-17$.
A simpler way of seeing that the answer cannot be right is that intuitively the covariance should be positive.
The problem lies with an incorrect calculation of $E(XY)$.