The formula
cov = Σ(x − x̄)(y − ȳ) / (n − 1)
What it means
Covariance averages the product of the two deviations from their means. When x is above its mean and y is too, the products are positive and the covariance comes out positive; when they move opposite ways, negative. The problem is magnitude: covariance is in the product of the two units and its size depends on the scale, so a big number does not mean a strong relationship. That is what correlation is for: a normalised covariance.
How to work it out by hand
- Work out the mean of each variable
- For each pair, multiply x's deviation by y's deviation
- Add all those products together
- Divide by n − 1 for the sample version, or by n for the population one
What is worth knowing
That covariance cannot be compared across different problems does not make it useless: it is the building block of the covariance matrix, and that matrix is at the heart of portfolio optimisation, principal component analysis and much of multivariate statistics. What you should not do is interpret it on its own: if you want to say "they move together a lot", the number to quote is the correlation.