Covariance
In statistics, covariance is a measure that tells us how two random variables vary together. If both variables tend to rise or fall at the same time, their covariance is positive. If one increases while the other decreases, it's negative.
Understanding covariance meaning helps us explore the strength and direction of a linear relationship between two variables.
1.0Covariance Meaning
Covariance describes the extent to which two random variables vary or move together. It’s not standardized, meaning its magnitude depends on the scale of the variables. The covariance of X and Y is given by:
Cov(X,Y)=n1∑i=1n(Xi−Xˉ)(Yi−Yˉ)
- If Cov(X, Y) > 0: X and Y tend to move in the same direction.
- If Cov(X, Y) < 0: X and Y tend to move in opposite directions.
- If Cov(X, Y) = 0: No linear relationship.
2.0Correlation and Covariance: The Difference
Covariance and correlation both describe how two variables are related. However, they differ:
So, while correlation and covariance both indicate the direction of a relationship, only correlation indicates its strength.
3.0How to Find Covariance
Let’s break down the steps to find covariance between two variables:
- Find the mean of both variables.
- Subtract the mean from each value.
- Multiply the deviations of corresponding values.
- Take the average of these products.
4.0Solved Examples on Covariance
Example 1: Let’s compute the covariance of X and Y with the following data:
Solution:
Step 1: Means
Xˉ=4,Yˉ=8
Step 2: Deviations and Products
Step 3: Average
Cov(X,Y)=34+0+4=38≈2.67
The positive covariance indicates that X and Y increase together.
Example 2: Given: X = [1, 2, 3] Y = [4, 5, 6]
Solution:
- Mean of X: Xˉ=31+2+3=2
- Mean of Y: Yˉ=34+5+6=5
Cov(X,Y)=31∑(Xi−Xˉ)(Yi−Yˉ)
Cov(X,Y)=31+0+1=32≈0.67
Example 3: Given: X = [1, 2, 3] Y = [6, 4, 2]
Solution:
Cov(X,Y)=3−2+0−2=3−4≈−1.33
Negative covariance indicates inverse relationship.
Example 4: Given: X = [2, 4, 6, 8] Y = [5, 10, 15, 20]
Solution:
Step 1: Xˉ=420=5,Yˉ=450=12.5
Cov(X,Y)=422.5+2.5+2.5+22.5=450=12.5
Strong positive linear relationship.
Example 5: Given: X = [1, 2, 3, 4], Y = [7, 7, 7, 7]
Solution:
Since Y is constant, Yˉ=7 and all deviations from the mean will be zero.
Cov(X,Y)=n1∑(Xi−Xˉ)(Yi−Yˉ)=0
Covariance = 0 when one variable is constant ⇒ No linear relationship.
Example 6 : Given: Math Scores (X) = [80, 85, 90], Science Scores (Y) = [78, 82, 88]
Solution:
Step 1: Xˉ=85,Yˉ=82.67
Cov(X,Y)=323.35+0+26.65=350≈16.67
Strong positive covariance: students doing well in one subject also do well in the other.
5.0Covariance in Statistics: Applications
Understanding covariance in statistics is essential in:
- Portfolio theory (to measure asset relationships)
- Regression analysis
- Principal component analysis (PCA)
- Machine learning algorithms
Covariance helps us grasp how two variables relate, even if it doesn’t tell us how strong that relation is.