Covariance and correlation of hypergeometric distribution In an urn with 90 marbles, 20 are green, 20 are black, and 50 are red. 
Jim draws 10 without replacement, let $X$ be the number of green marbles he gets. 
John draws 10 without replacement, let $Y$ be the number of green marbles he gets. 
Find $Cov(X, Y)$ and $Corr(X, Y)$. 
For $Cov(X,Y)$ I am trying to use the formula $Cov(X, Y) = E(XY) - E(X)E(Y)$. 
I've calculated $E(X)$ to be $10\times20/90$ and same for $E(Y)$ using the hypergeometric distribution. 
How is $E(XY)$ calculated? From the problem it seems like both draw from the same urn without replacement, so they are not independent of each other.  
 A: For $i=1,\ldots,20$, let us define an indicator random variable:
$$
I_i ~=~ \begin{cases} 1 & \text{if the $i$th marble drawn is green,} \\ 0 & \text{otherwise.} \end{cases}
$$
Then using this, what we seek is:
$$
\operatorname{cov}(I_1+\cdots+I_{10},\ I_{11}+\cdots+I_{20})
~=~ \sum_{i=1}^{10} \sum_{j=11}^{20} \operatorname{cov}(I_i,\  I_j).
$$
And we can find:
$$
\operatorname{cov}(I_i,\ I_j) ~=~ \operatorname{E}(I_iI_j) - \operatorname{E}(I_i)\operatorname{E}(I_j).
$$
$$
\operatorname{E}(I_i I_j) ~=~ \Pr(I_i=I_j=1).
$$
$$
\operatorname{E}(I_k) ~=~ \Pr(I_k=1).
$$
A: Alternatively, what you have obtained so far is that :
$$\mathsf E(X) ~=~ \mathsf E\Big(\sum_{i=1}^{10}G_i\Big)~=~\sum_{i=1}^{10}\mathsf P(G_i=1)~=~10\cdot(\dfrac{20}{90}) ~=~ \dfrac{20}9$$
$$\mathsf E(Y) ~=~ \sum_{j=11}^{20}\mathsf E(G_j)~=~ \dfrac{20}{9}$$
Where $G_i$ is the count of green balls in the $i$-th selection, which is either $0$ or $1$ (ie, an indicator random variable).  The first ten selections belong to Jim, the next to John, and the remainder remain where they were.
The process of finding $\mathsf E(X^2), \mathsf E(Y^2), \mathsf E(XY)$ is pretty much the same, though it makes use of:  $$\mathsf E(G_iG_j) ~=~ 1\cdot\mathsf P(G_i=1)\cdot\mathsf P(G_j=1\mid G_i=1)+0\color{silver}{\cdot \mathsf P(G_iG_j\neq 1)}$$
Hence, using Indicator Random Variables and the Linearity of Expectation:
$$\mathsf E(X^2) ~=~ \mathsf E(\sum_{i=1}^{10}G_i\cdot\sum_{j=1}^{10}G_j) ~=~ 10\cdot\mathsf E(G_i^2)+ 10\cdot 9\cdot\mathsf E(G_iG_j)\vert_{i\neq j}$$ 
$$\mathsf E(Y^2) ~=~ \mathsf E(\sum_{i=11}^{20}G_i\cdot\sum_{j=11}^{20}G_j) ~=~ 10\cdot\mathsf E(G_i^2)+ 10\cdot 9\cdot\mathsf E(G_iG_j)\vert_{i\neq j}$$ 
$$\mathsf E(XY) ~=~ \mathsf E(\sum_{i=1}^{10}G_i\cdot\sum_{j=11}^{20}G_j)~=~ 100\cdot\mathsf E(G_iG_j)\vert_{ i\neq j}$$
Then put it together.$$\begin{align}\mathsf{Cov}(X,Y) ~=&~\mathsf E(XY)-\mathsf E(X)\,\mathsf E(Y) \\[1.5ex] \mathsf {Var}(X)~=&~\mathsf E(X^2)-\mathsf E(X)^2 \\[1.5ex] \mathsf {Var}(Y)~=&~\mathsf E(Y^2)-\mathsf E(Y)^2\\[2.5ex] \mathsf {Corr}(X,Y) ~=&~\dfrac{\mathsf {Cov}(X,Y)}{\surd\mathsf {Var}(X)\;\surd\mathsf {Var}(Y)}\end{align}$$
