Summary
Expectation averages values under a probability law. Variance averages squared deviations from a mean. Covariance averages products of two variables’ deviations.
Suppose a hypothetical population gives probability to each pair , , and . How does their co-movement affect the spread of ? These are population probabilities, not four observations used to estimate an unknown population.
Covariance
Center both coordinates: the mean of is zero and the mean of is one. Multiply each point’s horizontal and vertical deviations, then average those products.
Reference drawing
Learning objective
Center the population to see spread, co-movement and the limits of correlation
Derivation
Expectation
For probability mass , . For a density , replace the sum by . Assume finite expectations. For constants , linearity gives
No independence is needed. An expectation need not be a possible outcome: a fair die has expectation .
Variance
Let and . Assume finite second moments. Variance squares one deviation; covariance multiplies two:
Expanding these expressions gives and .
Worked example
| Outcome | Probability | Centered product | ||
|---|---|---|---|---|
The means are and . The second moments are and . Thus , and .
Variance of a sum
Square , then average. The two cross-products produce the covariance term:
Here the variance is . Direct check: takes , with mean . Its squared deviations are , averaging . Removing dependence while retaining the marginals would instead give sum variance .
Correlation
Pearson correlation divides covariance by positive standard deviations and :
Here . It is undefined if either variance is zero. Correlation lies between and and does not establish an intervention effect.
Change the measurement
1. Convert the units of Y
New task: replace by without changing the joint observations.
Picture and change: each vertical deviation grows by . Covariance scales once; variance scales twice.
Check: covariance becomes and variance becomes . Correlation stays . A negative rescaling would reverse its sign.
Use when: units change but the underlying association does not.
2. Average correlated measurements
New task: average four variables, each with variance and pairwise correlation .
Picture and change: retain all six pairwise covariances, each equal to . Divide the full sum variance by .
Check: average variance is , not the independent value .
Use when: measurements share a user, environment or disturbance.
Zero covariance can hide dependence
Let be equally likely to be , and let . Both and are zero, so covariance is zero. Yet is determined by . Independence implies zero covariance under these moment conditions; the reverse implication fails.
Try averaging two independent quantities
Independent variables have variances and . Find the variance and standard deviation of their average.
Check your answer
The covariance term is zero. Variance is , and standard deviation is .
Scaling and repeated measurements
For constants , . Translation changes the mean but not spread. Standard deviation scales by . More generally,
For independent measurements with common variance , their mean has variance . Its standard error falls as , not . As another check, variances and covariance give sum variance .
Covariance matrices
For a random vector with mean , the covariance matrix is
The diagonal contains feature variances. Entry contains the covariance between features and .
A covariance matrix is symmetric and positive semidefinite. For any vector ,
This supports PCA, Gaussian models, whitening and uncertainty ellipsoids. Use a scatter plot alongside Pearson correlation: outliers can change it sharply. Spearman correlation instead measures association between ranks; it answers a different question about monotonic relationships.
In an interview
Reconstruct the sum-variance formula by centering and squaring. State the observation law, moment conditions and independence assumptions before simplifying it.
Common mistakes
- Saying zero correlation means independence.
- Treating correlation as evidence of intervention effects.
- Forgetting the covariance term in the variance of a sum.
- Saying variance scales linearly with the units of .
- Comparing covariances across variables with very different units.
- Using Pearson correlation without checking for nonlinearity or outliers.
Practice next
Use these quantities in bias and variance of estimators, SVD and PCA, and the ML math oral.