Covariance Calculator
Calculate sample or population covariance between two paired datasets, with means, sum of products, and Pearson correlation.
What Is Covariance?
Covariance measures how two variables move together. A positive covariance means they tend to increase together; a negative covariance means one tends to rise when the other falls. The magnitude depends on the units of both variables, so covariance is not standardized like correlation.
Sample and Population Formulas
Population covariance divides by $n$:
$$\mathrm{Cov_{pop}}(X,Y) = \frac{\sum_{i=1}^{n}(x_i - \bar{x})(y_i - \bar{y})}{n}$$
Sample covariance (an unbiased estimator of population covariance) divides by $n - 1$:
$$\mathrm{Cov_{sample}}(X,Y) = \frac{\sum_{i=1}^{n}(x_i - \bar{x})(y_i - \bar{y})}{n - 1}$$
Covariance vs Correlation
Correlation scales covariance by the product of the standard deviations, producing a unitless value between $-1$ and $1$. This calculator also reports Pearson $r$ when both standard deviations are positive, so you can compare association strength independently of units.
How to Use This Calculator
- Choose sample or population covariance.
- Paste paired values for Dataset X and Dataset Y (same length).
- Read covariance, means, the sum of deviation products, and Pearson correlation.
Example
For $X = \{2,4,6,8,10\}$ and $Y = \{3,5,7,11,13\}$, the means are $\bar{x}=6$ and $\bar{y}=7.8$. The sample covariance is positive, showing that larger $X$ values pair with larger $Y$ values.
Frequently Asked Questions
When should I use sample vs population covariance?
Use population covariance when your data is the entire group of interest. Use sample covariance when the pairs are a sample used to estimate a larger population.
Can covariance be greater than 1?
Yes. Covariance is not bounded by 1. Its scale depends on the units of X and Y. Use correlation if you need a normalized measure.
What does a covariance of zero mean?
A covariance near zero means there is no linear association in the data. The variables could still be related in a nonlinear way.
How is covariance related to correlation?
Pearson correlation equals covariance divided by the product of the two standard deviations (using the same divisor convention as the covariance you chose).
Related Tools
Explore related statistics tools: