# 6.2: Covariance


Covariance is a simple measure of the way two variables move together, or “co-vary”. The covariance of two variables, XX and YY, can be expressed in population notation as:

cov(X,Y)=E[(X−μx)(Y−μy)](6.2)(6.2)cov(X,Y)=E[(X−μx)(Y−μy)]

Therefore, the covariance between XX and YY is simply the product of the variation of XX around its expected value, and the variation of YY around its expected value. The sample covariance is expressed as:

cov(X,Y)=∑(X−¯X)(Y−¯Y)(n−1)(6.3)(6.3)cov(X,Y)=∑(X−X¯)(Y−Y¯)(n−1)

Covariance can be positive, negative, or zero. If the covariance is positive both variables move in the same direction, meaning if XX increases YY increases or if XX decreases YY decreases. Negative covariance means that the variables move in opposite directions; if XX increases YY decreases. Finally, zero covariance indicates that there is no covariance between XX and YY.

6.2: Covariance is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Jenkins-Smith et al. via source content that was edited to conform to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.