How to calculate covariance
Population covariance measures how two variables vary together. Subtract each variable's mean from its values, multiply the paired deviations, sum them, and divide by the number of pairs. For x = 1, 2, 3, 4 and y = 2, 4, 6, 8 the products of deviations sum to 10 over 4 pairs, so the covariance is 10 ÷ 4 = 2.5. The covariance of a variable with itself is simply its variance, which is a useful sanity check.
How to use this calculator
Enter up to four matching x and y pairs and leave unused rows blank. Both values of a pair must be filled to count. A positive result means the variables rise together; a negative one means they move oppositely. To standardize this into a −1 to +1 scale, see the correlation coefficient calculator.
Covariance vs. correlation
Covariance shows the direction of a relationship but its size depends on the units of the data. Correlation rescales covariance to a fixed −1 to +1 range, making strengths comparable. For relative spread of one variable, see the coefficient of variation calculator.
Frequently asked questions
- How do I calculate covariance?
- Multiply each pair's deviations from their means, sum the products, then divide by the number of pairs. For x = 1, 2, 3, 4 and y = 2, 4, 6, 8 the covariance is 2.5.
- Is this population or sample covariance?
- This calculator divides by n, giving the population covariance. Sample covariance would divide by n − 1.
- What does a positive covariance mean?
- It means the two variables tend to rise and fall together; a negative covariance means they move in opposite directions.
- How is covariance different from correlation?
- Covariance keeps the original units and has no fixed range, while correlation rescales it to between −1 and +1.
- Does a covariance of zero mean the variables are unrelated?
- Not necessarily — it only means there is no linear relationship. Two variables can be perfectly related in a curved pattern, such as y = x², and still return a covariance of zero. Plot the data before concluding that nothing connects them.