Skip to main content

Section 3.3

Variance, Covariance, and Correlation

You will be given this formula sheet on Checkpoints and the Final.

Question 3.3.1

Consider the following joint distribution between random variables \(X\) and \(Y\).

(X , Y) 1 2 3
0 0.10 0.15 0.05
1 0.20 0.30 0.10
2 0.05 0.03 0.02

(and of course, \(\mathbb{P}(X,Y) = 0\) otherwise.)

  1. Compute the variance of \(X\).

\[ \begin{aligned} \mathbb{E}[X] &= \sum_{x}\sum_{y}xp_{XY}(x,y) \\ &= 0p_X(0) + 1p_X[1] + 2p_X(2) \\ &= 0 + 1(0.20+0.30+0.10) + 2(0.05+0.03+0.02)\\ &= 0.80 \end{aligned} \] \[ \begin{aligned} \mathbb{E}[X^2] &= \sum_{x}\sum_{y}x^2p_{XY}(x,y) \\ &= 0^2p_X(0) + 1^2p_X[1] + 2^2p_X(2) \\ &= 0 + 1^2(0.20+0.30+0.10) + 2^2(0.05+0.03+0.02)\\ &= 1 \end{aligned} \] Thus,

\[ \begin{aligned} \operatorname{Var}(X) &= \mathbb{E}(X^2) - \left[\mathbb{E}(X)\right]^2\\ &= 1 - 0.8^2\\ &= 0.36 \end{aligned} \]

  1. Calculate the correlation between \(X\) and \(Y\).

The correlation between \(X\) and \(Y\) is \(\rho_{XY} = \frac{\mathbb{E}[XY] - \mathbb{E}[X]\mathbb{E}[Y]}{\sigma_X \sigma_Y}\)

\(\mathbb{E}(X)\) was calculated in part (a), and is 0.80.

\[ \begin{aligned} \mathbb{E}[Y] &= \sum_{x}\sum_{y}yp_{XY}(x,y) \\ &= 1p_Y[1] + 2p_Y(2) + 3p_Y(3) \\ &= 1(0.10+0.20+0.05) + 2(0.15+0.30+0.03) + 3(0.05+0.10+0.02)\\ &= 1.82 \end{aligned} \]

\[ \begin{aligned} \mathbb{E}[XY] &= \sum_{x}\sum_{y}xyp_{XY}(x,y) \\ &= (0)[1](0.10) + (0)(2)(0.15) + (0)(3)(0.05) + [1][1](0.20) + [1](2)(0.30) + [1](3)(0.10)\\ &+ (2)[1](0.05) + (2)(2)(0.03) + (2)(3)(0.02)\\ &= 1.44 \end{aligned} \]

To calculate the standard deviation/variance, we also need:

\[ \begin{aligned} \mathbb{E}[X^2] &= \sum_{x}\sum_{y}x^2p_{XY}(x,y) \\ &= 0^2p_X(0) + 1^2p_X[1] + 2^2p_X(2) \\ &= (0.20+0.30+0.10) + 4(0.05+0.03+0.02)\\ &= 1 \end{aligned} \] Thus, \(\sigma_X = \sqrt{\mathbb{E}[X^2] - \mathbb{E}[X]^2} = \sqrt{1 - 0.8^2} = 0.60\).

\[ \begin{aligned} \mathbb{E}[Y^2] &= \sum_{x}\sum_{y}y^2p_{XY}(x,y) \\ &= 1^2p_Y[1] + 2^2p_Y(2) + 3^2p_Y(3) \\ &= 1(0.10+0.20+0.05) + 4(0.15+0.30+0.03) + 9(0.05+0.10+0.02)\\ &= 3.80 \end{aligned} \]

Thus, \(\sigma_Y = \sqrt{\mathbb{E}[Y^2] - \mathbb{E}[Y]^2} = \sqrt{3.80 - 1.82^2} = 0.6983\).

Then,

\(\rho_{XY} = \frac{1.44 - (0.8)(1.82)}{0.60\times 0.6983} = -0.0382\)

Question 3.3.2

Let \(X\) and \(Y\) be continuous random variables with joint pdf \(f_{X,Y}(x,y) = 3xI_{[0,1]}(x)I_{[0, x]}(y)\).

  1. Compute the variance of \(X\).

\[ \begin{aligned} \mathbb{E}[X] &= \int_{0}^1\int_{0}^x(x)3xdydx\\ &= \int_{0}^1\int_{0}^x3x^2dydx\\ &= \int_{0}^1\left[3x^2y\Big|_{y = 0}^{y=x}\right]dx\\ &= \int_{0}^13x^2xdx\\ &= \int_{0}^13x^3dx\\ &= \frac{3}{4}x^4\Big|_{x=0}^{x=1}\\ &= \frac{3}{4} \end{aligned} \]

\[ \begin{aligned} \mathbb{E}[X^2] &= \int_{0}^1\int_{0}^x(x^2)3xdydx\\ &= \int_{0}^1\int_{0}^x3x^4dydx\\ &= \int_{0}^1\left[3x^3y\Big|_{y = 0}^{y=x}\right]dx\\ &= \int_{0}^13x^3xdx\\ &= \int_{0}^13x^4dx\\ &= \frac{3}{5}x^5\Big|_{x=0}^{x=1}\\ &= \frac{3}{5} \end{aligned} \]

Thus,

\[ \begin{aligned} \operatorname{Var}(X) &= \mathbb{E}[X^2] - \mathbb{E}[X]^2\\ &= \frac{3}{5} - \left(\frac{3}{4}\right)^2\\ &= 0.0375 \end{aligned} \]

  1. Compute the covariance between \(X\) and \(Y\).

\(E(X)\) was solved in part (a), and is 3/4.

\[ \begin{aligned} \mathbb{E}[Y] &= \int_{0}^1\int_{0}^x(y)3xdydx\\ &= \int_{0}^1\int_{0}^x3xydydx\\ &= \int_{0}^1\left[\frac{3}{2}xy^2\right]\Big|_{y = 0}^{y=x}dx\\ &= \int_{0}^1\frac{3}{2}x^3dx\\ &= \frac{3}{2\times4}x^4\big|_{x =0}^{x = 1}\\ &= \frac{3}{8}\\ \end{aligned} \]

\[ \begin{aligned} \mathbb{E}[XY] &= \int_{0}^1\int_{0}^x(xy)3xdydx\\ &= \int_{0}^1\int_{0}^x3x^2ydydx\\ &= \int_{0}^1\left[\frac{3}{2}x^2y^2\right]\Big|_{y= 0}^{y = x}dx\\ &= \int_{0}^1\frac{3}{2}x^4dx\\ &= \frac{3}{2\times5}x^5\Big|_{x = 0}^{x = 1}\\ &= \frac{3}{10} \end{aligned} \]

Thus,

\[ \begin{aligned} \operatorname{Cov}(X, Y) &= \mathbb{E}[XY] - \mathbb{E}[X]\mathbb{E}[Y]\\ &= \frac{3}{10} - \frac{3}{8} \frac{3}{4}\\ &= \frac{3}{160} \text{ or } 0.01875 \end{aligned} \]

Question 3.3.3

Suppose you roll a die. Let \(X\) be the number on the die and let \(Y = X^2\).

Compute \(\operatorname{Cov}(X, Y)\).

\[ \begin{aligned} \operatorname{Cov}(X, Y) &= \operatorname{Cov}(X, X^2)\\ &= \mathbb{E}(X\cdot X^2) - \mathbb{E}(X)\mathbb{E}(X^2)\\ &= \mathbb{E}(X^3) -\mathbb{E}(X)\mathbb{E}(X^2). \end{aligned} \] We have: \[ \begin{aligned} \mathbb{E}(X) = (1/6)(1) + (1/6)(2) + ... + (1/6)(6) = 7/2 \end{aligned} \] \[ \begin{aligned} \mathbb{E}(X^2) = (1/6)(1^2) + (1/6)(2^2) + ... + (1/6)(6^2) = 91/6 \end{aligned} \] \[ \begin{aligned} \mathbb{E}(X^3) = (1/6)(1^3) + (1/6)(2^3) + ... + (1/6)(6^3) = 147/2 \end{aligned} \]

Thus:

\[ \begin{aligned} \operatorname{Cov}(X, Y) &= \mathbb{E}(X^3) -\mathbb{E}(X)\mathbb{E}(X^2)\\ &= 147/2 - (7/2)(91/6)\\ &\approx 20.42 \end{aligned} \]

Question 3.3.4

Show that the variance of the \({\mathrm{Unif}}(L, R)\) distribution is given by the expression \(\frac{(R-L)^2}{12}\).

\(\operatorname{Var}(X) = \mathbb{E}(X^2) - \mathbb{E}(X)^2\)

\[ \begin{aligned} \mathbb{E}(X) &= \int_{L}^{R}x\cdot \frac{1}{R-L}dx\\ &= \frac{1}{2(R-L)}x^2\Bigg|_{x = L}^{X = R}\\ &= \frac{1}{2(R-L)}(R^2 - L^2)\\ &= \frac{1}{2(R-L)}(R + L)(R - L)\\ &= \frac{R+L}{2}\\ \end{aligned} \] \[ \begin{aligned} \mathbb{E}(X^2) &= \int_{L}^{R}x^2\cdot \frac{1}{R-L}dx\\ &= \frac{1}{3(R-L)}x^3\Bigg|_{x = L}^{X = R}\\ &= \frac{1}{3(R-L)}(R^3 - L^3)\\ &= \frac{1}{3(R-L)}(R - L)(R^2 + RL + L^2)\\ &= \frac{R^2 + RL + L^2}{3}\\ \end{aligned} \] Thus,

\[ \begin{aligned} \operatorname{Var}(X) &= \mathbb{E}(X^2) - \mathbb{E}(X)^2\\ &= \frac{R^2 + RL + L^2}{3} - \left( \frac{R+L}{2}\right)^2\\ &= \frac{R^2 + RL + L^2}{3} - \frac{R^2 + 2RL + L^2}{4}\\ &= \frac{4R^2 + 4RL + 4L^2}{12} - \frac{3R^2 + 6RL + 3L^2}{12}\\ &= \frac{R^2 - 2RL + L^2}{12} \\ &= \frac{(R - L)^2}{12} \end{aligned} \]

Question 3.3.5

Let \(X \sim {\mathrm{Exp}}(3)\) and \(Y \sim {\mathrm{Poiss}}(5)\). Assume \(X\) and \(Y\) are independent and let \(Z = X + Y\).

  1. Compute \(\operatorname{Cov}(X, Z)\).

\[ \begin{aligned} \operatorname{Cov}(X, Z) &= \operatorname{Cov}(X, X + Y) \\ &= \operatorname{Cov}(X, X) + \operatorname{Cov}(X, Y)\\ &= \operatorname{Var}(X) + 0 \text{ since X, Y are independent}\\ &= (1/3)^2\\ &= 1/9 \end{aligned} \]

  1. Compute \(\operatorname{Corr}(X, Z)\).

\[ \begin{aligned} \operatorname{Corr}(X, Z) &= \frac{\operatorname{Cov}(X, Z)}{\sigma_X\sigma_Z} \\ &= \frac{1/9}{(\sqrt{1/9})(\sqrt{1/9 + 5})} \text{ since independent}\\ &= 0.147 \end{aligned} \]

  1. Suppose \(Z = 4X-5\). What is the expected value and variance of \(Z\)?

\[ \begin{aligned} \mathbb{E}(Z) &= \mathbb{E}(4X-5) \\ &= 4\mathbb{E}(X) - 5\\ &= 4(\frac{1}{3}) - 5\\ &= -3.67 \end{aligned} \]

\[ \begin{aligned} \operatorname{Var}(Z) &= \operatorname{Var}(4X-5) \\ &= 4^2\operatorname{Var}(X)\\ &= 16(\frac{1}{3})^2\\ &= 1.78 \end{aligned} \]

Question 3.3.6

In any given 15 minute block of time, the R4 shows up with the “SORRY, BUS FULL” sign 5 times. Assume the arrival times of full buses are independent. Let \(X\) be the time in minutes between full buses.

What is the variance of the time between full buses? Show the full calculation.

First solve for \(\mathbb{E}[X]\)

\[ \begin{aligned} \mathbb{E}[X] &= \int_0^{\infty} xf_X(x)dx \\ &= \int_0^{\infty} x\frac{1}{3}e^{-1/3x}dx\\ &= \int_0^{\infty} \frac{1}{3}xe^{-1/3x}dx\\ \end{aligned} \] Let \(u = 1/3x \rightarrow du = 1/3dx\). Let \(dv =e^{1/3x}dx \rightarrow v = -3e^{-1/3x}\) Then by integration by parts….

\[ \begin{aligned} \mathbb{E}[X] &= \frac{1}{3}x(-3)e^{-1/3x} - \int_0^{\infty}(-3)e^{-1/3x}\frac{1}{3}dx\\ &= -xe^{-1/3x}|_{x = 0}^{x = \infty} + \int_{0}^{\infty} e^{-1/3x}dx\\ &= -xe^{-1/3x}|_{x = 0}^{x = \infty} -3e^{-1/3x}|_{x = 0}^{x=\infty}\\ &= (0-0) - (0 - 3)\\ &= 3 \end{aligned} \]

Now solve for \(\mathbb{E}[X^2]\) \[ \begin{aligned} \mathbb{E}[X] &= \int_0^{\infty} x^2f_X(x)dx \\ &= \int_0^{\infty} x^2\frac{1}{3}e^{-1/3x}dx\\ &= \int_0^{\infty} \frac{1}{3}x^2e^{-1/3x}dx\\ \end{aligned} \] Let \(u = 1/3x^2 \rightarrow du = 1/3xdx\). Let \(dv =e^{1/3x}dx \rightarrow v = -3e^{-1/3x}\) Then by integration by parts….

\[ \begin{aligned} \mathbb{E}[X^2] &= \frac{1}{3}x^2(-3)e^{-1/3x} - \int_0^{\infty}(-3)e^{-1/3x}\frac{2}{3}xdx\\ &= -x^2e^{-1/3x}|_{x = 0}^{x = \infty} + \int_{0}^{\infty} e^{-1/3x}dx\\ &= -x^2e^{-1/3x}|_{x = 0}^{x = \infty} + 6\int_{0}^{\infty} \frac{1}{3}e^{-1/3x}dx\\ &= (0-0) - 6(\mathbb{E}[X])\\ &= 6(3) = 18 \end{aligned} \]

Then:

\[ \operatorname{Var}[X] = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 = 18 - 3^2 = 9 \]

Aside: here are some general results for the exponential distribution:

If \(X \sim {\mathrm{Exp}}(\lambda)\), \(\mathbb{E}[X] = \frac{1}{\lambda}\), and \(\operatorname{Var}[X] = \frac{1}{\lambda^2}\)