Covariance Calculator

Measure how two data sets move together. Enter paired X and Y values to get the covariance, the Pearson correlation coefficient, and both means.

Results

Calculated
Covariance
Cov(X,Y)
Correlation Coefficient (r)
Pearson's r, from −1 to 1
Mean of X
Average of Data Set X
Mean of Y
Average of Data Set Y

How to use this calculator

Enter two data sets of equal length in Data Set X and Data Set Y, separated by commas or spaces, with each X value paired to the Y value in the same position. Choose Sample or Population covariance, then click Calculate. Click Clear to reset the fields to the example data.

What covariance measures

Covariance describes the direction of a linear relationship between two variables. For paired data (x, y), the formula is:

Cov(X,Y) = Σ(x − x̄)(y − ȳ) / (n − 1) for a sample, or divide by n instead of n − 1 for a full population.

Each term multiplies how far a given x is from the mean of X (x̄) by how far its paired y is from the mean of Y (ȳ). A positive covariance means X and Y tend to rise and fall together; a negative covariance means one tends to rise while the other falls; a value near zero means little linear relationship.

Why the correlation coefficient is also shown

Covariance's size depends on the units of X and Y, so a covariance of 500 could mean a strong or a weak relationship depending on what is being measured. The Pearson correlation coefficient, r = Cov(X,Y) / (σx × σy), rescales the same relationship to always fall between −1 and 1, making the strength of the relationship easy to read regardless of units.

Interpreting the results

The Covariance card shows the raw Cov(X,Y) value in the sign convention above. The Correlation Coefficient card shows the same relationship rescaled to −1 to 1: values near 1 indicate a strong positive linear relationship, values near −1 indicate a strong negative one, and values near 0 indicate little linear relationship. The Mean of X and Mean of Y cards show the average of each data set, which the covariance formula is built around.

Frequently Asked Questions

What is covariance in simple terms?
Covariance measures whether two variables tend to move together. A positive covariance means that when one variable is above its own average, the other tends to be above its average too. A negative covariance means one tends to be above average while the other is below. A covariance near zero means there is little linear relationship between the two.
What is the formula for covariance?
For paired data (x, y), covariance is Cov(X,Y) = Σ(x − x̄)(y − ȳ) / (n − 1) for a sample, or divide by n instead of n − 1 for an entire population. Each term multiplies how far x is from its mean by how far the paired y is from its mean, then averages those products.
Should I use sample or population covariance?
Use sample covariance (dividing by n − 1) when your data is a sample drawn from a larger population, which is the most common case in real-world analysis. Use population covariance (dividing by n) only when your data set represents every member of the population you care about, with nothing left out.
How is covariance different from correlation?
Covariance shows the direction of a linear relationship (positive or negative) but its size depends on the units of X and Y, so it cannot be compared across different data sets. The Pearson correlation coefficient rescales covariance to always fall between −1 and 1, making it easier to judge how strong the relationship is regardless of units.