@wikipedia


{\rm cov}(x,y) = \frac{1}{n}  \sum_{i=1}^n (x_i - \bar x) (y_i - \bar y)

where  are discrete variables and  are their means