# Finding variance of joint probability function of discrete random variables

I've been working on a problem, and it's quite lengthy, so I'm going to restrict the problem while not losing too much information.

I'm given a table of the discrete random variables $X$ and $Y$. I'm asked to find the variance of $Y-X$. The solution breaks down each possible case of $Y-X$ and provides the probability of it. Then it found the expected value of $Y-X$. Neither were a problem for me. However, when attempting to find the variance, the solution simply gave a long sum of numbers. I tried to generalize it (hopefully without any mistakes) and obtained this: $$\text{Var}(Y-X) = \sum_{w \in W}\text{P}(W=w)\cdot[w - \text{E}(W)]^2, \text{ where } W = Y-X \tag{1}$$ Again, I haven't seen this before. I am however, familiar with $$\text{Var}(aX+bY) = a^2\text{Var}(X) + b^2\text{Var}(Y) + 2ab\cdot\text{Cov}(X,Y).$$ Are the two somehow equivalent? If not, where does $(1)$ come from?

-
If $W = Y-X$, and you spent a fair amount of time determining the distribution of $W$ already (that is, finding $P(W=w)$ for all choices of $w$, as well as calculating its expected value $E[W]$), what formula would you use in calculating the variance of $W$? –  Dilip Sarwate Mar 5 '13 at 23:29

## 1 Answer

Here is the definition of variance: Var(W) = E[(W-E[W])^2]

Note that (W-E[W])^2 is a random variable and denote Z=(W-E[W])^2.

So, to find the expectation of a random variable, you sum Pr(Z=z)*Z. And that's how you will get the equation (1) - in your question.

Also for your equation (2), it could be proven by using the definition by doing some algebra.

And yes, (1) and (2) are equivalent based on the fact they are both correct expressions regarding the variance.

-