1. ## [SOLVED] 2 questions

Let X be the number of 1's and Y the number of 2's that occur in n rolls of a fair die. Compute Cov(X,Y).

Do I use $Cov(X, Y)= E[XY] -E[X]E[Y]$?

A fair die is rolled. Let X and Y denote, respectively, the number of rolls necessary to obtain a 6 and a 5. Find E[X|Y=5].

2. Hello,
Originally Posted by noob mathematician
Let X be the number of 1's and Y the number of 2's that occur in n rolls of a fair die. Compute Cov(X,Y).

Do I use $Cov(X, Y)= E[XY] -E[X]E[Y]$?
Why not ?
You can compute E[X] and E[Y] I guess ^^ (same binomial distributions)
$\mathbb{E}(XY)=\sum_{k=0}^n\sum_{l=0}^n k \cdot l \cdot \mathbb{P}(X=k,Y=l)=\sum_{k=0}^n\sum_{l=0}^n k \cdot l \cdot \mathbb{P}(Y=l|X=k)\mathbb{P}(X=k)$
$=\sum_{k=0}^n k \cdot \mathbb{P}(X=k) \sum_{l=0}^n l \cdot \mathbb{P}(Y=l|X=k)$

For the distribution $\mathbb{P}(Y=l|X=k)$, note that it's equivalent to saying "what is the probability to get l 2's, while there already had k 1's ?
You can also see that l can get values only between 0 and n-k.
And that it follows a binomial distribution (n-k,1/5) ~ Z

So we actually have :
$\mathbb{E}(XY)=\sum_{k=0}^n k \cdot \mathbb{P}(X=k) \sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)$

But $\sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)$ looks like a lot $\mathbb{E}(Z)$, doesn't it ?

Can you try to do this ?

3. Originally Posted by Moo
Hello,

Why not ?
You can compute E[X] and E[Y] I guess ^^ (same binomial distributions)
$\mathbb{E}(XY)=\sum_{k=0}^n\sum_{l=0}^n k \cdot l \cdot \mathbb{P}(X=k,Y=l)=\sum_{k=0}^n\sum_{l=0}^n k \cdot l \cdot \mathbb{P}(Y=l|X=k)\mathbb{P}(X=k)$
$=\sum_{k=0}^n k \cdot \mathbb{P}(X=k) \sum_{l=0}^n l \cdot \mathbb{P}(Y=l|X=k)$

For the distribution $\mathbb{P}(Y=l|X=k)$, note that it's equivalent to saying "what is the probability to get l 2's, while there already had k 1's ?
You can also see that l can get values only between 0 and n-k.
And that it follows a binomial distribution (n-k,1/5) ~ Z

So we actually have :
$\mathbb{E}(XY)=\sum_{k=0}^n k \cdot \mathbb{P}(X=k) \sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)$

But $\sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)$ looks like a lot $\mathbb{E}(Z)$, doesn't it ?

Can you try to do this ?
I have some doubt again..

So $E[X]=E[Y]=\frac{n}{6}$
Then from your equation $\sum_{k=0}^n k \cdot \mathbb{P}(X=k)=E[X]=\frac{n}{6}$ too..
However I'm stuck with $\sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)$, especially the (n-k) part

By the way the answer is $-\frac{n}{36}$, so it must imply that $\sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)=\frac{n-1}{6}$

But how do I obtain it?

4. Originally Posted by noob mathematician
So $E[X]=E[Y]=\frac{n}{6}$
Then from your equation $\sum_{k=0}^n k \cdot \mathbb{P}(X=k)=E[X]=\frac{n}{6}$ too..
Yes, but the sum isn't exactly this !
There is the sum $\sum_{l=0}^{n-k}\dots$, which depends on k, so you can't just calculate the two sums separately.

I'm sorry I should've added brackets :

$\sum_{k=0}^n \left(k \cdot \mathbb{P}(X=k) \cdot \sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)\right)$
However I'm stuck with $\sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)$, especially the (n-k) part
Actually, do you understand why $\mathbb{P}(Y=l|X=k)=\mathbb{P}(Z=l)$, where Z follows a binomial distribution (n-k,1/5) ?
Do it with words : P(Y=l|X=k) is the probability that there are l 2's, while there are k 1's, among n numbers. So it means that there already have k 1's, leaving us with n-k 'undefined' numbers.
But, there can't be any 1's left in these n-k, since they're included in the k numbers (X=k is the total of 1's among the n numbers). So there are 5 remaining possibilities : {2,3,4,5,6}
Thus, P(Y=l|X=k) is equal to P(Z=l), where Z follows a binomial distribution (n-k,1/5)

Does it look better this way ?

Now the sum :
$\sum_{l=0}^{n-k} l \cdot \mathbb{P}(Z=l)=\mathbb{E}(Z)=\frac{n-k}{5}$

Then you're left with :
$\mathbb{E}(XY)=\sum_{k=0}^n k \cdot \mathbb{P}(X=k) \cdot \frac{n-k}{5}=\frac 15 \left(n \sum_{k=0}^n k \cdot \mathbb{P}(X=k)-\sum_{k=0}^n k^2 \cdot \mathbb{P}(X=k)\right)$

But $\sum_{k=0}^n k \cdot \mathbb{P}(X=k)=\mathbb{E}(X)=\frac n6$

And $\sum_{k=0}^n k^2 \cdot \mathbb{P}(X=k)=\mathbb{E}(X^2)=Var(X)+[\mathbb{E}(X)]^2=n \cdot \frac 16 \cdot \frac 56+\frac{n^2}{36}=\frac{n^2+5n}{36}$

Finally, $\mathbb{E}(XY)=\frac 15 \left(\frac{n^2}{6}-\frac{n^2+5n}{36}\right)=\frac 15 \cdot \frac{5n^2-5n}{36}=\frac{n^2-n}{36}$

And you get the desired result