Covariance is a statistical measure that quantifies the degree to which two variables change together. It indicates the direction of the linear relationship between variables.
\(x_i\) and \(y_i\) are individual values of variables X and Y
\(\bar{x}\) and \(\bar{y}\) are the means of X and Y
\(n\) is the number of data points
Calculation Steps
Calculate the mean of X and Y separately.
For each pair of data points, subtract the X mean from the X value and the Y mean from the Y value.
Multiply these differences for each pair.
Sum all these products.
Divide the sum by the number of data points.
Example Calculation
Let's calculate the covariance for X = (1, 2, 3, 4, 5) and Y = (2, 4, 5, 4, 5)
Calculate means: \(\bar{x} = 3\), \(\bar{y} = 4\)
Calculate differences and products:
(1 - 3)(2 - 4) = 4
(2 - 3)(4 - 4) = 0
(3 - 3)(5 - 4) = 0
(4 - 3)(4 - 4) = 0
(5 - 3)(5 - 4) = 2
Sum the products: 4 + 0 + 0 + 0 + 2 = 6
Divide by n: 6 / 5 = 1.2
Therefore, the covariance is 1.2.
Visual Representation
This scatter plot represents the example dataset. The pattern shows a generally positive relationship, consistent with the positive covariance we calculated.
Need a Custom Calculator?
We can create a free, personalized calculator just for you!