# How do you calculate the covariance between two discrete variables?

$\text{Cov} \left(X , Y\right) = \frac{1}{n} {\sum}_{i = 1}^{n} {x}_{i} {y}_{i} - \left(\frac{1}{n} {\sum}_{i = 1}^{n} {x}_{i}\right) \left(\frac{1}{n} {\sum}_{i = 1}^{n} {y}_{i}\right)$
Consider $\left({x}_{i} , {y}_{i}\right) \forall i = 1 \left(1\right) n$.
$\text{Cov} \left(X , Y\right) = \frac{1}{n} {\sum}_{i = 1}^{n} {x}_{i} {y}_{i} - \left(\frac{1}{n} {\sum}_{i = 1}^{n} {x}_{i}\right) \left(\frac{1}{n} {\sum}_{i = 1}^{n} {y}_{i}\right)$