Equivalence of two formulas for variance and covariance

1.7k Views Asked by At

I know two formulas for variance:

$$\operatorname{variance}(f) = \operatorname{expectation}((f(x) - \operatorname{expectation}(f^2(x)) \\ = \operatorname{expectation}(f(x)^2) - \operatorname{expectation}(f(x))^2$$

How are these two the same?

Also how is $$\operatorname{cov}[x, y] = E((x − E[x])(y − E[y])) = E[xy] − E[x]E[y]$$

1

There are 1 best solutions below

3
On BEST ANSWER

Let $X, Y$ be random variables with means $\mu_X = \mathrm{E}[X]$ and $\mu_Y = \mathrm{E}[Y]$. Then $$\begin{align*} \mathrm{Cov}[X,Y] &\equiv \mathrm{E}[(X - \mu_X)(Y - \mu_Y)] \\ &= \mathrm{E}[XY - \mu_Y X - \mu_X Y + \mu_X \mu_Y] \\ &= \mathrm{E}[XY] - \mathrm{E}[\mu_Y X] - \mathrm{E}[\mu_X Y] + \mathrm{E}[\mu_X \mu_Y] \\ &= \mathrm{E}[XY] - \mu_Y \mathrm{E}[X] - \mu_X \mathrm{E}[Y] + \mu_X \mu_Y \\ &= \mathrm{E}[XY] - \mu_X \mu_Y - \mu_X \mu_Y + \mu_X \mu_Y \\ &= \mathrm{E}[XY] - \mu_X \mu_Y \\ &= \mathrm{E}[XY] - \mathrm{E}[X]\mathrm{E}[Y]. \end{align*}$$

If $X = Y$, then $\mathrm{Cov}[X,Y] = \mathrm{Var}[X]$, $XY = X^2$, and the above becomes $$\mathrm{Var}[X] = \mathrm{E}[X^2] - \mathrm{E}[X]^2.$$ Now suppose $W = f(X)$; i.e., $W$ is a random variable that is some function $f$ of the random variable $X$. Then $$\mathrm{Var}[W] = \mathrm{E}[W^2] - \mathrm{E}[W]^2$$ is equivalent to $$\mathrm{Var}[f(X)] = \mathrm{E}[f^2(X)] - \mathrm{E}[f(X)]^2.$$