Covariance evaluates how two continuous numerical variables change together across a shared sample of observations.
It assesses whether above-average values of one variable tend to correspond with above-average values of another.
For each paired observation, calculate deviations from their respective sample means for both variables.
Multiply the two deviations together to form a product of deviations for that individual pair.
When both variables sit above their means, their deviations are positive, producing a positive product.
When both variables sit below their means, their deviations are negative, producing a positive product as well.
Summing these products and dividing by sample size minus one yields the sample covariance between the two variables.
A positive covariance indicates that the two variables generally rise and fall together in the same direction.
A negative covariance indicates an inverse pattern where one variable rises while the other falls.
A covariance near zero suggests that no consistent linear co-movement exists between the paired variables.
For example, outdoor temperature and air conditioning electricity usage typically exhibit positive covariance.
However, covariance is an unstandardised metric whose magnitude depends directly on the original measurement units.
Measuring height in millimetres instead of metres multiplies covariance by one thousand without altering the underlying relationship.
Because its scale is unbounded and unit-dependent, covariance cannot indicate how strong the association is.
In data science, covariance matrices organise pairwise covariances across multiple features, forming the core of multivariate analysis.