Covariance Calculator
Sample and population covariance of two variables, with correlation and a step table.
Sample covariance = Σ(xᵢ − x̄)(yᵢ − ȳ) ÷ (n − 1); population covariance divides by n instead. A positive value means X and Y rise together, a negative value means one falls as the other rises.
Free, runs in your browser. Nothing you enter is uploaded.
How to use it
- Paste the X values and the Y values in the same order.
- Read the sample and population covariance.
- Check the step table and the correlation to judge strength.
What you enter
- Paired X and Y values
What you get
- Sample covariance
- Population covariance
- Correlation r
- Step table
Formula
s_xy = Σ(xᵢ − x̄)(yᵢ − ȳ) ÷ (n − 1) | σ_xy = Σ(xᵢ − μx)(yᵢ − μy) ÷ n | r = s_xy ÷ (s_x s_y)
Worked example
Input: X: 2, 4, 6, 8; Y: 3, 7, 5, 10
Result: Sample cov 6.33, population cov 4.75, r = 0.82
X and Y increase together.
Questions
How do you calculate covariance?
Subtract the mean from each X and each Y, multiply the paired deviations, add the products, and divide by n − 1 for a sample (n for a whole population).
What is the difference between covariance and correlation?
Correlation is covariance divided by the product of the two standard deviations. It is unit-free and always between −1 and 1, so it shows strength; covariance only shows direction.
Can covariance be negative?
Yes. Negative covariance means that when one variable is above its mean, the other tends to be below its mean.
When do I divide by n − 1?
When your data are a sample used to estimate the population covariance. Dividing by n − 1 removes the bias.
Limitations
- Covariance depends on units, so values cannot be compared across different variable pairs.
References
Related reading
- Covariance Formula: Definition and Calculation Examples
- What Is a Covariance Matrix? Definition, Formula and Examples
More Statistics
- Standard Deviation Calculator
- Mean, Median & Mode Calculator
- Variance Calculator
- Z-Score Calculator
- P-Value Calculator
- Confidence Interval Calculator
- T-Test Calculator
- Chi-Square Test Calculator
- Correlation Coefficient Calculator
- Linear Regression Calculator
- Normal Distribution Calculator
- Probability Calculator
All free tools · By Dr. Zubair Khalid, DVM, MS, PhD.