Statistics

Covariance Matrix

Every point and the mean are two corners of a rectangle. Up-right and down-left of the mean it counts as positive, the other two corners as negative, and the covariance is the average of all those signed areas. Put it beside the two variances and you have the matrix.

positive rectangle: both above or both below the meannegative rectangle: one above, one below

Hover a point to see its rectangle · drag a point to move it

—
—

fallingrising
Values
mean (x̄, ȳ)—
σx, σy—
positive area / n—
negative area / n—
correlation ρ—

What to observe

  1. Hover a point. Its rectangle runs from the point to the mean, and its area (x − x̄)(y − ȳ) is positive up-right or down-left of the mean andnegative otherwise. cov(x, y) is the average of all of them.
  2. On Falling the red rectangles outweigh the teal ones and cov turns negative. With No relation they cancel, and cov sits near zero.
  3. The diagonal is the same idea with x against itself: the average square (x − x̄)², which is the variance. Stretch x and var x grows by the square, cov grows by the stretch, but ρ does not move: correlation has no units.
  4. On Curved, y is decided by x completely, yet cov ≈ 0. The rectangles on the left cancel the ones on the right: covariance only sees straight-line trends.
  5. The ellipse's long and short axes are the eigenvectors of this matrix, which is exactly where PCAstarts.

Shortcuts:r reset · f fullscreen