Covariance is a measure of joint-variability of two random variables.

Mathematically speaking, it is defined as: Where:

  • X, Y = two random variables
  • cov(X,Y) = covariance between X, Y
  • E[.] = expectation of the input random variable

This can be further simplified to: