Formulas » Maths Formulas » Covariance Formula

Covariance Formula

Covariance formula: Explore more with the Covariance formula with a solved example.

Covariance formula

Covariance states the relationship between two random variables. The formula is applied to get the variance between two variables. It states that till what range with the change in one variable changes together. If one variable is of a higher range other will also have a higher range and lower the one variable other would be of a lower range. Covariance is measured in units.

Positive covariance-

When both the variables move in the same direction it is called positive covariance.

Negative covariance-

When both the variables move in opposite directions it is said as negative covariance.

In the formula of covariance, the covariance between two variables X and Y can be denoted as Cov(x,y). The formula of covariance varies in some circumstances. Formulas for the covariance of population and sample are different.

Covariance formula for population

 Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N)

Covariance formula for sample

 Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N – 1)

Where, Xi –values of the X-variable

             Yi – values of the Y-variable

             X̄ – mean of the X-variable

             Ȳ – mean of the Y-variable

             n – number of data points

The covariance formula can be also written as

ρ(X,Y)=Cov(X,Y)/σX * σY

ρ(X,Y)      – correlation between the variables X and Y

Cov(X,Y) –  covariance between the variables X and Y

σX           –  standard deviation of the X-variable

σY            – standard deviation of the Y-variable

Example

1. Find covariance for following data  x = {6,5,3,4,2}, y = {12,10,8,6,4}

Given data, x = {6,5,3,4,2}, y = {12,10,8,6,4} & N = 5

                    X̄ = (6 + 5 + 3 + 4 + 2) / 5

                       = 20 / 5

                       = 4

                   Ȳ  = (12 + 10 +8 + 6 + 4) / 5

                       = 40 / 5

                       = 8

Using the sample covariance formula

  Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N – 1)

    = [(6 – 4)(12 – 8) + (5 – 4)(10 – 8) + (3 – 4)(8 – 8) + (4 – 4)(6 – 8) + (2 – 4)(4 – 8)] / 5 – 1

     = 8 + 2 + 0 + 0 + 6 / 4

      = 16 / 4

       = 4

Using the Population covariance formula

 Cov(x,y) = ∑(xi – x ) × (yi – y)/ (N)

= [(6 – 4)(12 – 8) + (5 – 4)(10 – 8) + (3 – 4)(8 – 8) + (4 – 4)(6 – 8) + (2 – 4)(4 – 8)] / 5

= 8 + 2 + 0 + 0 + 6 / 5

= 16 / 5

= 3.2

2. The standard deviation of X is 15 and the standard deviation of Y is 20. The correlation between X and Y is 5. Find covariance of X and Y.

Given data, σX =15, σY =20 and  ρ(X,Y) = 5

ρ(X,Y) = Cov(X,Y)/σX * σY

5= Cov(X,Y)/ 15*20

Cov(X,Y)= 1500

faq

Frequently asked questions

Get answers to the most common queries related to the Covariance Formula.

What is the relation between Correlation and Covariance?

Ans. Both the terms are used in regression analysis and statistics. But they are opposite in nature. Correlation sho...Read full

What is homogeneous between Correlation and Covariance?

Ans. Correlation and Covariance are used to measure the relationship between two variables. This states that if a co...Read full