Covariance & Correlation Matrices
Line up two columns of a health survey, height and weight; variance scores them one at a time, but pair their gaps and a single `np.cov(data)` call folds the whole spreadsheet's spread and tilt into one grid of numbers.
- ▸Pair a column with itself and the two-column spread measure hands back its plain variance.
- ▸Rescale a column centimetres to metres and its raw pairing number drops a hundredfold; the unit-free twin holds.
- ▸Widen a scatter and one number grows; tilt it and another grows, four numbers hold the cloud's shape.
Two columns of a health survey, height and weight, clearly move together: the tall people are mostly the heavy ones. Variance only scores one column at a time, though. For a single number on the pairing, run the same recipe across both columns at once: for each person, multiply how far their height sits from average height by how far their weight sits from average weight, then average those products over everyone. That average is the covariance. A positive number means the two rise together, a negative one means one rises as the other falls. Pair a column with itself and the products become squared gaps, so the covariance collapses back to that column's plain variance.