Covariance Calculator


This statistics calculator is intended for calculation of the mean values and covariance of two given sets of data points. Enter the data sets of input points in the appropriate fields of the Covariance Calculator and calculate the above parameters as well as the number of input values (dataset size). You can paste the data copied from a spreadsheet or csv-file or input manually using comma, space or enter as separators.


Precision: decimal places

Dataset X

Dataset Y

Number of values:
Mean value of X:
Mean value of Y:
Covariance of X,Y:


Formula for covariance

This online Covariance Calculator estimates the statistical relationship between two sets of population data of random variables \(X\) and \(Y\). Covariance shows us how much these data sets vary together and to what extent they are related to each other. It not only tells us if there is a relationship between them, but also which direction that relationship is in.

A positive covariance means that the two sets are positively related, and they have the same direction. In other words it indicates that the two random variables tend to move in the same direction. A negative covariance means that the two sets are negatively related, and they have the opposite directions. Or, that the two random variables tend to move in the opposite directions.

Population covariance, \(cov(X,Y)\), between two data sets of random variables \(X\) and \(Y\) is determined by the covariance formula:

$$cov(X,Y)=\frac { 1 }{ n } \sum _{ i=1 }^{ n }{ ({ x }_{ i } } -\overline { X } )({ y }_{ i }-\overline { Y } ),$$

where \(\overline { X }\) is the mean of \(X\), \(\overline { Y }\) is the mean of \(Y\) and \(n\) is the number of elements in \(X\) and \(Y\).

Properties of Covariance

1. The covariance of a random variable with itself is its variance:

$$cov(X,X)={ \sigma }^{ 2 }(X).$$

2. The covariance is symmetrical:

$$cov(X,Y)=cov(Y,X).$$

3. If the random variables \(X\) and \(Y\) are independent, then:

$$cov(X,Y)=0.$$

4. The constant factor can be taken out of the covariance sign:

$$cov(aX,Y)=cov(X,aY)=a\cdot cov(X,Y).$$

5. The covariance will not change if a constant is added to one of the random variables (or to both at once):

$$cov(X+a,Y)=cov(X,Y+a)=cov(X+a,Y+b)=cov(X,Y).$$

6. From the above it follows:

$$cov(aX+b,cY+d)=ac\cdot cov(X,Y).$$

7. For random variables with finite variance holds the following inequality:

$$|cov(X,Y)|\leq \sqrt{\sigma^{2} (X)\cdot \sigma^{2} (Y)}.$$

8. The variance of the sum (difference) of random variables is equal to the sum of their variances plus (minus) doubled covariance of these random variables:

$$\sigma^{2} (X\pm Y)=\sigma^{2} (X)+\sigma^{2} (Y)\pm 2\cdot cov(X,Y).$$

Applications of Covariance

Covariance is widely used in genetics and molecular biology, in meteorological and oceanographic data processing, in statistics and image processing, etc.

Covariance have significant applications in finance and portfolio management. It can help determine if stocks’ returns tend to move with or against each other, and, thus, predict how two stocks might perform relative to each other in the future. Using the covariance calculations, investors might even be able to select stocks that complement each other in terms of price movement.


Related calculators

Check out our other statistics calculators such as Correlation Coefficient Calculator or Outlier Calculator.