Home / Wiki / C / Covariance

Covariance

Economics Markets and Financial TheoryUpdated 15 Nov 2026

Covariance is a measure of the joint variability of two variables. If the two tend to be above their averages at the same time and below their averages at the same time, their covariance is positive. If one tends to be above its average when the other is below, the covariance is negative. A value near zero means there is no consistent linear relationship between them.

In finance the variables are usually the returns of two assets. Covariance is the quantity that determines how much risk is removed when assets are combined, which makes it the central input of modern portfolio theory. It is also the building block of correlation, of beta, and of the regression methods used throughout quantitative finance.

01

Formula and example

The sample covariance of two series is:

sxy=1n−1∑i=1n(xi−xˉ)(yi−yˉ)s_{xy} = \frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})
  • xix_i and yiy_i are the paired observations, for example the returns of two shares in period ii.
  • xˉ\bar{x} and yˉ\bar{y} are the sample means of the two series.
  • nn is the number of pairs.

Suppose share X returned 2, 4, 6, 8 and 10 percent in five periods and share Y returned 1, 3, 2, 5 and 4 percent. The means are 6 and 3. The deviations of X from its mean are −4, −2, 0, 2 and 4, and those of Y are −2, 0, −1, 2 and 1. Multiplying them pair by pair gives 8, 0, 0, 4 and 4, which sum to 16. Dividing by n−1=4n - 1 = 4 gives a covariance of 4.

The units of this figure are percent squared, which has no intuitive meaning. That is why covariance is usually converted into something easier to read.

02

Relationship to correlation and beta

Dividing covariance by the product of the two standard deviations gives the correlation coefficient, a number between −1 and +1:

ρxy=sxysx sy\rho_{xy} = \frac{s_{xy}}{s_x \, s_y}

In the example, the variance of X is 10 and that of Y is 2.5, so the standard deviations are 3.16 and 1.58. The correlation is 4 ÷ (3.16 × 1.58) = 4 ÷ 5 = 0.8. The covariance of a variable with itself is its variance, so variance is a special case.

Dividing covariance by the variance of one variable gives the slope of a linear regression of the other on it. In the example, the slope of Y on X is 4 ÷ 10 = 0.4. When X is the return on the market, this slope is the asset's beta, the measure of market risk used in the capital asset pricing model. The same ratio gives the minimum-variance hedge ratio when one instrument is used to hedge another.

03

Role in portfolio risk

The variance of a portfolio of two assets is:

σp2=w12σ12+w22σ22+2w1w2 σ12\sigma_p^2 = w_1^2 \sigma_1^2 + w_2^2 \sigma_2^2 + 2 w_1 w_2 \, \sigma_{12}
  • w1w_1 and w2w_2 are the weights of the two assets.
  • σ12\sigma_1^2 and σ22\sigma_2^2 are their variances.
  • σ12\sigma_{12} is their covariance.

The last term is what makes diversification work. When the covariance is low or negative, the portfolio's variance is less than the weighted average of the individual variances. With many assets, the number of covariance terms far exceeds the number of variance terms, so the risk of a large portfolio is driven almost entirely by how its holdings move together and hardly at all by their separate volatilities.

04

The covariance matrix

For a set of assets, all the variances and covariances are arranged in a square table called the covariance matrix. It is the main input to portfolio optimization, to risk parity weighting and to parametric value at risk.

The matrix grows quickly. For NN assets it holds N(N+1)/2N(N+1)/2 distinct numbers, which for 500 shares is 125,250. Estimating so many values from a limited history is unreliable, and with fewer observations than assets the sample matrix cannot be inverted, which standard optimization requires. Practitioners deal with this in several ways. A factor model explains co-movement through a small number of common drivers, reducing the count of parameters. Shrinkage blends the sample matrix with a simpler, more stable target. Hierarchical risk parity avoids inverting the matrix at all.

05

Limitations

Covariance captures only linear association. Two variables can be strongly related in a nonlinear way and still have a covariance of zero, so zero covariance does not mean independence. It is also sensitive to extreme observations, since a single large joint move can dominate the sum.

For financial returns the main difficulty is instability. Covariances change through time and tend to rise sharply in market stress, when assets that normally move separately fall together. An estimate from a calm period then understates risk exactly when it matters. Estimates also depend on the sampling interval: assets that trade at different hours or infrequently show artificially low covariance in daily data. Many risk systems therefore weight recent observations more heavily or model covariance as changing over time, and test portfolios against stressed values as well as estimated ones.

Last updated 15 Nov 2026