Covariance
Measures how two variables vary together.
Formula
Variables
Example
Positive = move together
How it works
Covariance measures whether two variables tend to be above or below their own averages at the same time. Each pair contributes a product: if both values are above their means or both are below, the product is positive; if one is above and the other below, the product is negative. Averaging these products gives a single signed value that summarizes the direction of joint variation.
When to use it
Use covariance when you want to check whether two quantitative variables move together and in what direction, such as returns on two assets, study time and test score, or temperature and ice cream sales. It is especially useful as a building block for correlation, regression, and portfolio analysis.
Worked example, step by step
Suppose we have paired data: X = 1, 2, 3 and Y = 2, 0, 4. Step 1: Find the means. \bar{x} = (1+2+3)/3 = 2 \bar{y} = (2+0+4)/3 = 2 Step 2: Compute each deviation product. (1-2)(2-2) = (-1)(0) = 0 (2-2)(0-2) = (0)(-2) = 0 (3-2)(4-2) = (1)(2) = 2 Step 3: Add the products. 0 + 0 + 2 = 2 Step 4: Divide by n = 3. \text{cov}(X,Y) = 2/3 Final answer: \text{cov}(X,Y) = 0.6667 (approximately) Interpretation: the covariance is positive, so larger X values tend to be associated with larger Y values in this dataset.
Common mistakes to avoid
- Forgetting to subtract the mean from each value before multiplying
- Assuming covariance has to lie between -1 and 1; that is true for correlation, not covariance
- Mixing up population and sample formulas and using n when the task requires n-1
Did You Know?
Covariance can be any size, which is why statisticians usually rescale it into the more interpretable correlation.
Share this formula
More in Statistics & Probability
View allArithmetic Mean
BasicThe average of a data set.
Median
BasicThe middle value separating the higher and lower halves.
Variance
IntermediateAverage squared deviation from the mean.
Standard Deviation
IntermediateSquare root of the variance; typical spread.
Z-Score
IntermediateNumber of standard deviations a value is from the mean.
Bayes' Theorem
IntermediateUpdates a probability given new evidence.