# What is the covariance of the number of red and green balls?

A bag has 10 red, 8 green, and 12 blue balls. I randomly grab 12 balls from the bag without replacement. Let $X$ be the number of red balls grabbed and $Y$ be the number of green balls grabbed. What is the covariance of $X$ and $Y$?

I began by creating a indicator random variable $I_i$ that is 1 if the $i$th ball grabbed is 1 and 0 otherwise as well as $J_i$, which is 1 if the $i$th ball grabbed is green and 0 otherwise. Then,

$$Covariance(I_1, J_1) = E(I_1 J_1) - E(I_1)E(J_1) = 0 - (\frac{10}{30})(\frac{8}{30}) \\ Covariance(I_1, J_2) = E(I_1 J_2) - E(I_1)E(J_2) = (\frac{10}{30})(\frac{8}{29}) - (\frac{10}{30})(\frac{8}{30}$$

I got stuck here, and read the solutions, which read:

$$Covariance(X, Y) = 12 Covariance(I_1, J_1) + (12)(11) Covariance(I_1, J_2) = \frac{-96}{145}$$

Where did this last equation come from? Why are we multiplying one of the covariances by 12 and the other one by 12 times 11?

-

Since $X=\sum_{n=1}^N I_n$ and $Y =\sum_{m=1}^N J_m$ $$\mathbb{Cov}(X,Y) = \sum_{n,m} \mathbb{Cov}(I_n,J_m) = \sum_{n} \mathbb{Cov}(I_n,J_n) + \sum_{n \not= m} \mathbb{Cov}(I_n,J_m)$$ Since $(I_n,J_n)$ are exchangeable random variables, $\mathbb{Cov}(I_n,J_n)$ does not depend on $n$, as well $\mathbb{Cov}(I_n,J_m)$ is the same for all $n \not = m$. Thus $$\mathbb{Cov}(X,Y) = N \mathbb{Cov}(I_1,J_1) + N(N-1) \mathbb{Cov}(I_1, J_2)$$