AI Tutor
A scatter plot lets your eyes spot whether two variables rise or fall together, but your eyes cannot give you an exact mathematical measurement.
How do statisticians distill that simultaneous upward or downward drift into a single, reliable number?

Moving Together: The Centroid Split

While sample variance measures how a single variable spreads out around its mean, sample covariance measures how two quantitative variables vary together. In 1888, English statistician Francis Galton introduced this concept while studying whether tall parents reliably have taller-than-average children.
If you split a scatter plot using the centroid (xˉ,yˉ)(\bar{x}, \bar{y})—the balance point formed by the mean of XX and the mean of YY—every data point falls into one of four distinct quadrants.
When points lie in the top-right or bottom-left quadrants, both deviations share the same sign, making their product positive. Points in the other two quadrants produce negative products.
So how do we combine all of these individual quadrant products into one overall score?

The Sample Covariance Formula

For a sample of nn paired observations, the sample covariance (sxys_{xy}) is the sum of all paired deviation products divided by nβˆ’1n - 1.
sxy=βˆ‘i=1n(xiβˆ’xΛ‰)(yiβˆ’yΛ‰)nβˆ’1s_{xy} = \frac{\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})}{n - 1}
We divide by nβˆ’1n - 1 rather than nn because sample deviations are calculated from the sample means rather than the true population means, which would slightly underestimate the true spread without this Bessel correction.