Covariance is just like correlation - it tells you how two random variables change together - with the difference that covariance is not necessarily bounded / normalized between .
In fact, the covariance matrix is the unnormalized correlation matrix.
The covariance between two variables and is calculated as the average of the product of their deviations from their respective means and .
Derivation Properties:
Covariance can be interpreted as:
→when increases, tends to increase as well, and vice versa.
→ when increases, tends to decrease, and vice versa.
→ no linear relationship between and .
The covariance of a random variable and itself is its variance
The order of the variables does not matter (commutative property)
Limitations
Covariance does not indicate the strength of the relationship, nor its causality. So if two distributions are independent, their covariance will be zero but the reverse it not true because it does not take non-linear relationsips into account. However, if distributions are multivarate normal, a zero covariance implies independence.
It is also sensitive to the scale of the variables, making it difficult to compare covariances across different datasets.
Covariance Matrix
Covariance matrix
The second moment of a random variable is → The second moment matrix contains all pairwise – dot products ().
When centered (mean subtracted), this becomes the covariance matrix (or “central second moment”):
See also multivariate gaussian distribution for a more detailed and visual overview.
How much somone likes some fruite example table (higher score means they like the fruit more):
Apple | Banana |
---|---|
1 | 1 |
3 | 0 |
-1 | -1 |
The means of both random variables:
The covariance matrix of these two random variables has the following form:
Since, → (we know the elements of one triangle, we can just mirror it).