Variance, Covariance, and Correlation
Last modified — 02 Dec 2026
By the end of this lecture, students are anticipated to be able to:
Calculate variance and covariance from continuous and discrete random variables/distributions
Utilize properties of variance and covariance
The variance is a measure of the spread of the distribution of \(X\) around its mean \(\mathbb{E}[X]\).
The variance of a random variable \(X\) is defined by \[ \begin{aligned} \sigma^2_X &= \operatorname{Var}(X) \\ &= \mathbb{E}[(X - \mathbb{E}[X])^2] &\text{(this is the ``definition"...)}\\ &= \mathbb{E}[X^2] - \mathbb{E}[X]^2 & \text{(... but this version is often easier for calculations)} \end{aligned} \]
The standard deviation of a random variable \(X\) is defined by \[\sigma_X = \sqrt{\operatorname{Var}(X)}.\]
(Where the variance exists.)
Recall if \(X \sim Unif(L,R)\), then \[f_X(x; L, R) = \frac{1}{R-L}I_{[L,R]}(x)\]
Let \(X \sim {\mathrm{Unif}}(0,1)\). Find \(\operatorname{Var}(X)\).
Let \(X \sim {\mathrm{Exp}}(\lambda)\). Find \(\operatorname{Var}(X)\).
You may use the fact that \(\mathbb{E}[X] = 1/\lambda\) and that \(\Gamma(z) = (z-1)!\) for integer \(z > 1\).
If we have two random variables \(X\) and \(Y\), we can quantify the linear relationship between them using covariance.
The covariance between two random variables \(X\) and \(Y\) is defined by \[\operatorname{Cov}(X, Y) = \mathbb{E}[(X - \mathbb{E}[X])(Y - \mathbb{E}[Y])].\]
We can compute the covariance using the joint PMF/PDF of \(X\) and \(Y\).: \[\begin{aligned} \operatorname{Cov}(X, Y) &= \sum_{x} \sum_{y} (x - \mathbb{E}[X])(y - \mathbb{E}[Y]) p_{X,Y}(x, y).\\ \operatorname{Cov}(X, Y) &= \int_{-\infty}^\infty \int_{-\infty}^\infty (x - \mathbb{E}[X])(y - \mathbb{E}[Y]) f_{X,Y}(x, y) \, \mathsf{d}x \, \mathsf{d}y. \end{aligned}\]
Let \(X\) be the number of heads in 5 tosses of a fair coin, and let \(Y\) be the number of tails in the same 5 tosses.
Hint: If \(Z\sim {\mathrm{Binom}}(n, \theta)\), then \(\operatorname{Var}(Z) = n\theta(1-\theta)\).
Let \(X\) and \(Y\) be random variables with finite variances.
Covariance is not a standardized measure of the relationship between \(X\) and \(Y\).
For example, if we multiply \(X\) by 100, then \(\operatorname{Cov}(X, Y)\) will also be multiplied by 100.
The correlation between two random variables \(X\) and \(Y\) is defined by \[\rho_{XY} = \operatorname{Corr}(X, Y) = \frac{\operatorname{Cov}(X, Y)}{\sigma_X \sigma_Y}.\]
Returning to the heads or tails example, we have that \[\begin{aligned} \rho_{XY} &= \frac{\operatorname{Cov}(X, Y)}{\sigma_X \sigma_Y} = \frac{-5/4}{\sqrt{5/4} \sqrt{5/4}} = -1. \end{aligned}\]
Let X and Y be discrete random variables with the following joint distribution:
| P(X, Y) | Y = 2 | Y = 4 |
|---|---|---|
| X = 1 | 0.2 | 0.3 |
| X = 3 | 0.1 | 0.4 |
Hint: \(\sigma_X=1\) and \(\sigma_Y = 0.92\).
Calculate the correlation between \(X\) and \(Y\).
Midterm 2 is in class on Friday November 20 (testing sections 2.4 (continuous RV/distributions) to 3.2 (expected values))
Practice problems have been posted on the website.
Cheat sheet rules:
Calculator rules:
Stat 302 - Winter 2025/26