A measure of linear dependence

1. of a sample

Given a sample of \(n\) pairs of values \(x_i, y_i\) with means \(\mu_x\) and \(\mu_y\), the covariance is defined as
\[ \frac{1}{n}\sum_{i=1}^{n}\left(x_i - \mu_x\right) \times \left(y_i - \mu_y\right) \]
where \(\sum\) is the summation sign.

2. of a distribution

For a pair of random variables \(X\) and \(Y\) having a given joint distribution with means of \(\mu_X\) and \(\mu_Y\), the covariance is equal to the expectation of the function
\[ f(X, Y) = \left(X - \mu_X\right) \times \left(Y - \mu_Y\right) \]