Recipe
Compute correlation from a joint distribution
Use when: you have a full joint table (or covariance plus both standard deviations) and need \rho_{X,Y}
Goal: a single unitless number between -1 and 1 measuring the strength and direction of the linear relationship between X and Y
Taught in Correlation · extends Compute covariance from a joint distribution
Quick recipe
-
1
Get E(X), E(Y), and E(XY) from the joint table exactly as in the covariance recipe, then apply \operatorname{Cov}(X,Y)=E(XY)-E(X)E(Y).
Example
Using the same table as the covariance recipe, p(0,0)=0.2, p(0,1)=0.1, p(1,0)=0.1, p(1,1)=0.6: E(X)=E(Y)=0.7, E(XY)=0.6, so \operatorname{Cov}(X,Y)=0.6-(0.7)(0.7)=0.11.
Why: correlation is built directly on top of covariance, so the first real step is producing that number.
-
2
Compute each variable's own variance from its marginal distribution (the ordinary variance formula from earlier in the course), then take the square root of each.
Example
Both marginals here are \operatorname{Bernoulli}(0.7), so \operatorname{Var}(X)=\operatorname{Var}(Y)=(0.7)(0.3)=0.21, giving \sigma_X=\sigma_Y=\sqrt{0.21}\approx0.458.
Why: correlation needs both spreads to cancel the units out of covariance's raw, unit-dependent number.
-
3
Multiply the two standard deviations together, then divide the covariance from Step 1 by that product.
Example
\rho_{X,Y} = \frac{0.11}{(0.458)(0.458)} = \frac{0.11}{0.21} \approx 0.524⚡ Shortcut
Since \sigma_X and \sigma_Y are always positive (they're square roots), the SIGN of \rho_{X,Y} always matches the sign of \operatorname{Cov}(X,Y). If only the direction of the relationship is needed, not its exact strength, the sign of the covariance alone already answers it, no division required.
Why: dividing by both standard deviations is exactly what strips the units out, leaving a pure number the next step can check against a fixed bound.
-
4
Confirm the result sits between -1 and 1. If it doesn't, a covariance or standard-deviation value earlier in the computation was miscomputed.
Example
0.524 sits safely inside [-1,1], confirming no arithmetic slip in the steps above.
Why: correlation's own defining bound makes this the cheapest possible check on the whole computation, the same reasoning the second worked example below relies on.
Common mistakes
- Dividing covariance by the variances instead of the standard deviations, forgetting to take the square root of each.
- Mixing up which variable's variance feeds \sigma_X and which feeds \sigma_Y.
- Reporting a correlation outside [-1,1] without going back to find the arithmetic error.
- Treating a correlation near 0 as proof of no relationship at all, when it only rules out a LINEAR one.