[Math] Covariance of two random variables

combinatoricscovarianceexpectationprobabilityrandom variables

I am trying to find the covariance of two random variables but I am not having any lucky. Just for simplicity lets say that my random variables are :

X = value rolled by a die

Y = 1 if even 0 if odd

Just from intuiting $E(Y) = .5$ and $E(X) = 3.5$

Now how do I find the covariance? I can't find an explanation of how this works anywhere. I see that the formula is

$cov(XY) = E(XY) – E(X)E(Y)$

but no one anywhere thought it would be a good idea and explain what E(XY) is or how to compute it.

Anyways I found some hints and they said to multiply each pair by each other, but then what do I do with them? Add them? I wasn't sure I tried everything I could and never got the correct answer.

Going with what I think is the most correct thing to do I find the E(XY) by taking the value at each point and multiplying it by the probability of each at each point and then summing them all up.

So for $E(X_1, Y_1)$ I get an X value of 1 with probability $1/6$ and a Y value of 0 with probability $1/6$ So my value for that pair is $1/6$ From here would I then do 2, 3, 4, 5, 6 and sum up each one to determine the cross product expected value?

I have tried this a dozen times and it results in not the correct answer for my other problems. Is this simple example correct? Where did I go wrong?

Best Answer

First of all, a bit of intuition. The covariance of two random variables is a statistic that tells you how "correlated" two random variables are. If two random variables are independent, then their covariance is zero. If their covariance is nonzero, then the value gives you an indication of "how dependent they are".

Now, onto your problem.

I think you might find some use in the general formula for calculating expectations. For any random variable $X$ taking discrete values in $\mathbb{N}$, and any nonnegative measurable function $f$, you have

$$ \mathbb{E}[f(X)]=\sum_{k\in\mathbb{N}}f(k)\mathbb{P}(X=k). $$

In your specific example, $Z=XY$ is a new random variable, and not a couple $(X,Y)$ as you seem to write in your example.

So, $Z$ is a random variable. What values does it take? Let us look at all the possibilities:

$$ \mathbb{P}(Z=1)=\mathbb{P}(X=1,Y=1)=0, $$

because if $X=1$ then $Y=0$. Similarly,

$$ \mathbb{P}(Z=2)=\mathbb{P}(X=2,Y=1)=\mathbb{P}(X=2)=\frac16, $$ because if $X=2$ then $Y=1$. Continuing the process, you find

$$ \mathbb{P}(Z=3)=\mathbb{P}(X=5)=0,\text{ and }\mathbb{P}(Z=4)=\mathbb{P}(Z=6)=\frac16. $$

It remains to note that $Z$ can also take the value 0, and this happens whenever $Y=0$:

$$ \mathbb{P}(Z=0)=\mathbb{P}(X=1)+\mathbb{P}(X=3)+\mathbb{P}(X=5)=\frac16+\frac16+\frac16=\frac12. $$

Once you know all the probabilities characterizing the distribution of $Z$, you can compute its expectation according to the previous formula:

$$ \mathbb{E}[Z]=2\cdot\frac16+4\cdot\frac16+6\cdot\frac16+0\cdot\frac12=\frac{12}6=2. $$

Related Question