A measure of the relationship between random variables

Over 1.8 million professionals use CFI to learn accounting, financial analysis, modeling and more. Start with a free account to explore 20+ always-free courses and hundreds of finance templates and cheat sheets. Start Free

What is Covariance?

In mathematics and statistics, covariance is a measure of the relationship between two random variables. The metric evaluates how much – to what extent – the variables change together. In other words, it is essentially a measure of the variance between two variables. However, the metric does not assess the dependency between variables.

Covariance - Image of an individual checking financial reports on a tablet

Unlike the correlation coefficient, covariance is measured in units. The units are computed by multiplying the units of the two variables. The variance can take any positive or negative values. The values are interpreted as follows:

  • Positive covariance: Indicates that two variables tend to move in the same direction.
  • Negative covariance: Reveals that two variables tend to move in inverse directions.

In finance, the concept is primarily used in portfolio theory. One of its most common applications in portfolio theory is the diversification method, using the covariance between assets in a portfolio. By choosing assets that do not exhibit a high positive covariance with each other, the unsystematic risk can be partially eliminated.

CFI’s Math for Corporate Finance Course explores the financial mathematics concepts required for Financial Modeling.

Formula for Covariance

The covariance formula is similar to the formula for correlation and deals with the calculation of data points from the average value in a dataset. For example, the covariance between two random variables X and Y can be calculated using the following formula (for population):

Covariance Formula (Population)

For a sample covariance, the formula is slightly adjusted:

Covariance Formula (Sample)


  • X– the values of the X-variable
  • Yj – the values of the Y-variable
  • X̄ – the mean (average) of the X-variable
  • Ȳ – the mean (average) of the Y-variable
  • n – the number of data points

Covariance vs. Correlation

Covariance and correlation both primarily assess the relationship between variables. The closest analogy to the relationship between them is the relationship between the variance and standard deviation.

Covariance measures the total variation of two random variables from their expected values. Using covariance, we can only gauge the direction of the relationship (whether the variables tend to move in tandem or show an inverse relationship). However, it does not indicate the strength of the relationship, nor the dependency between the variables.

On the other hand, correlation measures the strength of the relationship between variables. Correlation is the scaled measure of covariance. It is dimensionless. In other words, the correlation coefficient is always a pure value and not measured in any units.

The relationship between the two concepts can be expressed using the formula below:

Covariance vs. Correlation - Formula


  • ρ(X,Y) – the correlation between the variables X and Y
  • Cov(X,Y) – the covariance between the variables X and Y
  • σ– the standard deviation of the X-variable
  • σY – the standard deviation of the Y-variable

Example of Covariance

John is an investor. His portfolio primarily tracks the performance of the S&P 500 and John wants to add the stock of ABC Corp. Before adding the stock to his portfolio, he wants to assess the directional relationship between the stock and the S&P 500.

John does not want to increase the unsystematic risk of his portfolio. Thus, he is not interested in owning securities in the portfolio that tend to move in the same direction.

John can calculate the covariance between the stock of ABC Corp. and S&P 500 by following the steps below:

1. Obtain the data.

First, John obtains the figures for both ABC Corp. stock and the S&P 500. The prices obtained are summarized in the table below:

Covariance Sample Data

2. Calculate the mean (average) prices for each asset.

Mean S&P 500 ABC Corp Data

3. For each security, find the difference between each value and mean price.

Covariance Sample Table

4. Multiply the results obtained in the previous step.

5. Using the number calculated in step 4, find the covariance.

covariance calculation

In such a case, the positive covariance indicates that the price of the stock and the S&P 500 tend to move in the same direction.

Additional Resources

To keep learning and advancing your career, the following CFI resources will be helpful:

0 search results for ‘