Ad Space — Top Banner

Covariance Formula

Measure how two variables change together.
Essential for portfolio analysis, regression, and data science.

The Formula

Cov(X, Y) = Σ (xᵢ - x̄)(yᵢ - ȳ) / (n - 1)

Covariance measures the direction of the relationship between two variables. A positive value means they tend to increase together. A negative value means one increases as the other decreases.

Variables

SymbolMeaning
Cov(X, Y)Covariance between variables X and Y
xᵢ, yᵢIndividual data points
x̄, ȳMean (average) of X and Y
nNumber of data points

Example 1

Find covariance for X = {1, 2, 3} and Y = {2, 4, 5}

x̄ = (1+2+3)/3 = 2, ȳ = (2+4+5)/3 = 3.67

Σ(xᵢ - x̄)(yᵢ - ȳ) = (1-2)(2-3.67) + (2-2)(4-3.67) + (3-2)(5-3.67)

= (-1)(-1.67) + (0)(0.33) + (1)(1.33) = 1.67 + 0 + 1.33 = 3.0

Cov(X,Y) = 3.0 / (3-1) = 1.5 (positive — they increase together)

Interpreting Covariance

  • Cov > 0: Variables tend to move in the same direction
  • Cov < 0: Variables tend to move in opposite directions
  • Cov ≈ 0: No clear linear relationship

When to Use It

Use covariance when:

  • Building an investment portfolio (diversification analysis)
  • Performing linear regression analysis
  • Exploring relationships between variables in data science
  • Calculating the correlation coefficient (which normalizes covariance)

Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.