# How to calculate variance of W? Find the probability distribution of W?

$W=Y-X$

I have figured out that $E(W)=0.3$ by using this formula $E(X+Y)=E(X)+E(Y)$.

I tried using the same formula with $E(X^2)$ and $E(Y^2)$ to find $E(W^2)$.

I also tried using $V(X+Y)=V(X)+V(Y)+2Cov(X,Y)$, but changing all the positive signs to negative, to find the Variance of W.

Here is the joint distribution of $X$ and $Y$:

$$\begin{array}{c||c|c|c} & Y=0 & Y=1 & Y=2 \\\hline X=0 & 0.1 & 0.1 & 0.2 \\ X=1& 0.3 & 0.2 & 0.1 \end{array}$$

What I think I got right.

• $E(X) = 0.6$
• $E(Y) = 0.9$
• $E(X^2) = 0.6$
• $E(Y^2) = 1.5$
• $X$ and $Y$ are not independent

I am also definitely mixing when I can use what formula and when I can't.

• $E(W^2) = 1.3$
• $Var(W)=1.21$
• Need more information about the relationship between $X$ and $Y$. Also what is the first itemized list? $\bullet XY - 0.0 - 1.0$ etc.? – jdods Jul 14 '16 at 14:09
• It is the probability distribution table with 2 variables, I think it's called. – David Lund Jul 14 '16 at 14:11
• ah. the edit messed up your text. I'll go in and fix it with proper tabular format. – jdods Jul 14 '16 at 14:12
• Does the edit now seem to reflect your wishes? Feel free to edit it more to your liking. Hope this helps. – jdods Jul 14 '16 at 14:24
• Yes, thank you :) Perfect! I am going to have to learn do edit like that myself soon. – David Lund Jul 14 '16 at 14:25

The easiest thing to do is to first compute the probability distribution of $W$ from the joint distribution of $X$ and $Y$; then use this to compute $\operatorname{Var}[W]$ directly.

to this end, simply create a table for $W$ using the table for $X$ and $Y$:

$$\begin{array}{|c|c|c|c|} \hline x & y & w & \Pr[(X,Y) = (x,y)] \\ \hline 1 & 0 & -1 & 0.3 \\ \hline 1 & 1 & 0 & 0.2 \\ \hline 1 & 2 & 1 & 0.1 \\ \hline 0 & 0 & 0 & 0.1 \\ \hline 0 & 1 & 1 & 0.1 \\ \hline 0 & 2 & 2 & 0.2 \\ \hline \end{array}$$

Then collapse this table for distinct values of $w$, that is to say, add the rightmost column values for each row with the same value of $w$:

$$\begin{array}{|c|c|} \hline w & \Pr[W = w] \\ \hline -1 & 0.3 \\ \hline 0 & 0.2 + 0.1 = 0.3 \\ \hline 1 & 0.1 + 0.1 = 0.2 \\ \hline 2 & 0.2 \\ \hline \end{array}$$

This gives the desired probability distribution of $W$

Now the expectation and variance are trivially computed from this table: $$\operatorname{E}[W] = -1(0.3) + 0(0.3) + 1(0.2) + 2(0.2) = 0.3 \\ \operatorname{E}[W^2] = (-1)^2 (0.3) + 0^2 (0.3) + 1^2 (0.2) + 2^2 (0.2) = 1.3 \\ \operatorname{Var}[W] = \operatorname{E}[W^2] - \operatorname{E}[W]^2 = 1.21.$$

If you calculated the variance from the joint distribution of $X$ and $Y$ directly, then you'd need to go back to get the probability distribution of $W$ for the second part of your question, anyway.

• Hi, you don't think you know about any videos that can maybe explain how to make that table. I don't quite get it. My book does not explain it at all, I think. I see that you take Y-X, and you get W, literally 0-1=-1. But I don't get much more than that. – David Lund Jul 14 '16 at 17:19
• @DavidLund All I did in the first table was rearrange the table in your question. The first, second, and fourth columns in my first table are taken directly from your table. The third column is just the calculation of $w = y - x$ from the first two columns. Then, in the second table I created, I just dropped the $x$ and $y$ columns, and for the $w$ column, I added together the two rows from the first table for which $w = 0$; and I also added together the two rows from the first table for which $w = 1$. – heropup Jul 14 '16 at 17:28
• Okey, I did not realize that, but now I am so happy. Thanks. – David Lund Jul 14 '16 at 17:56

Now you calculate $\mathbb E(W^2)$

$\mathbb E(W^2)=\sum_{i=1}^2 \sum_{j=1}^3 (w_{ij})^2 \cdot p(w_{ij})$

$\mathbb E(W^2)=\sum_{i=1}^2 \sum_{j=1}^3 (x_i-y_j)^2 \cdot p(x_i,y_j)$

$=0^2\cdot 0.1+(0-1)^2\cdot 0.1+(0-2)^2\cdot 0.2+(1-0)^2\cdot 0.3+(1-1)^2\cdot 0.2+(1-2)^2\cdot 0.1=1.3$

And finally

$Var(X-Y)=Var(W)=\mathbb E(W^2)-[\mathbb E(W)]^2=1.3-(0.6-0.9)^2=1.21$

with $\mathbb E(W)=\mathbb E(X)-\mathbb E(Y)$

Remark

You can use the formula $V(X+Y)=V(X)+V(Y)+2Cov(X,Y)$ as well.

$Cov(aX,bY)=abCov(X,Y)$

In your case $a=1$ and $b=-1$. Thus $Cov(X,-Y)=-Cov(X,Y)$

And $Cov(X,Y)=\sum_{y=0}^2 \sum_{x=0}^1 p(x,y)\cdot (x-E(x))\cdot (y-E(y))$

$=0.1\cdot (-0.6)\cdot (-0.9)+(-0.1\cdot 0.6\cdot 0.1)+0.2\cdot (-0.6)\cdot 1.1+0.3\cdot 0.4\cdot (-0.9)+0.2\cdot 0.4\cdot 0.1+0.1\cdot 0.4\cdot 1.1=-0.14$

Thus $Cov(X,-Y)=0.14$

And $Var(X)=\mathbb E(X^2)-[\mathbb E(X)]^2=0.6-0.6^2=0.24$

$Var(Y)=\mathbb E(Y^2)-[\mathbb E(Y)]^2=1.5-0.9^2=0.69$

Therefore $Var(X-Y)=0.24+0.69+2\cdot 0.14=1.21$

• So I also got -0.14. So if one of them, either X or Y is negative, the Cov will become negative as well? Cov(X,−Y)=−Cov(X,Y) – David Lund Jul 14 '16 at 17:11
• Not in general. Here you have an example. X is postive and -Y is negative, but the covariance is positive. Maybe you have meant the following:".So if one of them, either $X$ or $Y$ is negative, the Cov will have the opposite sign of $Cov(X,Y)$". You statement $Cov(X,-Y)=-Cov(X,Y)$ is right. – callculus Jul 14 '16 at 17:17
• Yea, that is what I meant. I realized that I needed 0.14, but I got -0.14. So is it like that always? What if both are negative? I haven't been studying this for a long time. – David Lund Jul 14 '16 at 17:22
• @DavidLund Just use the formula $Cov(aX,bY)=abCov(X,Y)$. What do you get for $Cov(-X,-Y)$ ? – callculus Jul 14 '16 at 17:23
• That's a handy formula. + :D I am going to write that down, definitely. Thanks – David Lund Jul 14 '16 at 17:26