Covariance and correlation
Covariance quantifies how two variables move together. Positive covariance means they tend to increase together; negative covariance means one tends to decrease as the other increases. However, the magnitude of covariance depends on the scale of the variables, making it hard to compare across datasets.
The Pearson correlation coefficient normalizes covariance to a range of -1 to 1, making it scale-independent. A value near 1 indicates strong positive linear association, near -1 indicates strong negative linear association, and near 0 indicates no linear association.
Cov(X,Y) = Σ(xᵢ − x̄)(yᵢ − ȳ) / (n−1)
Sample covariance using Bessel's correction.
r = Cov(X,Y) / (sₓ × sᵧ)
Pearson correlation: covariance divided by the product of standard deviations.