Eric S. answered 12/17/21
I am a PhD student in Finance. I have an MBA and MS in Economics.
The easiest way to remember the formula for the covariance between two variables (X,Y) is "covariance equals the expectation of the product minus the product of the expectations." In equation form, this is expressed as equation 1:
#1: cov(X,Y) = E[X*Y] - [E(X)*E(Y)]
Note: Equation 1 is actually the result of multiplying out the formal definition for covariance, which is:
DEFINITION: cov(X,Y) = E[(X-E[X])(Y-E[Y])]
We'll start with equation 2 and manipulate it to show it equals equation 1:
#2: E[X(Y-μy)]
The expectation operator E[.] is linear in parameters, so we can use the distributive property to multiply the expression out.
→E[XY-Xμy]
→E[XY]-E[Xμy]
μy, the mean of Y, is a constant value. The expectation of a constant is itself. So, E[μy] = μy.
#3: E[XY]-[E[X]μy]
Regarding notation, the expressions E(Y) and μy are identical. So, equation 3 can be expressed as equation 4:
#4: E[XY] - [E(X)*E(Y)]
Equation 4 is the right-hand side of equation 1, which equals Cov(X,Y). Thus, we have proven that equation 2, E[X(Y-μy)], equals Cov(X,Y).