Collect paired data values ((x_i, y_i)) for (i = 1, 2, dots, n)
Compute the mean of (x): (bar{x} = frac{1}{n}sum_{i=1}^{n} x_i)
Compute the mean of (y): (bar{y} = frac{1}{n}sum_{i=1}^{n} y_i)
Subtract the means from each value: ((x_i – bar{x})) and ((y_i – bar{y}))
Multiply each pair of deviations: ((x_i – bar{x})(y_i – bar{y}))
Sum the products: (sum_{i=1}^{n}(x_i – bar{x})(y_i – bar{y}))
Divide by (n) for population covariance: (mathrm{Cov}(X,Y) = frac{1}{n}sum_{i=1}^{n}(x_i – bar{x})(y_i – bar{y}))
Divide by (n-1) for sample covariance: (s_{xy} = frac{1}{n-1}sum_{i=1}^{n}(x_i – bar{x})(y_i – bar{y}))
