StatlectThe Digital Textbook
Index > Glossary

Covariance formula

The covariance between two random variables X and Y can be computed using the definition of covariance:[eq1]where the capital letter $QTR{rm}{E}$ indicates the expected value operator.

Formula for discrete variables

When the two random variables are discrete, the above formula can be written as[eq2]where $R_{XY}$ is the set of all couples of values of X and Y that can possibly be observed and [eq3] is the probability of observing a specific couple $\left( x,y\right) $. This sum is a weighted average of the products of the deviations of the two random variables from their respective means.

To see how to apply this formula, read some Solved exercises.

Formula for continuous variables

When the two random variables, taken together, form a continuous random vector, the formula can be expressed as a double integral:[eq4]where [eq5] is the joint probability density function of X and Y.

To see how to apply this formula, read some Solved exercises.

A simple covariance formula

Using the formulae above to compute covariance can sometimes be tricky. This is the reason why the following simpler (and equivalent) covariance formula is often used:[eq6]

For instance, this formula is straightforward to use when we know the joint moment generating function of X and Y. Taking partial derivatives of the joint moment generating function, we can derive the moments [eq7], [eq8] and [eq9] and then plug their values in this formula.

More details

In the lecture entitled Covariance you can find more details about this formula, including a proof of it and some exercises.

Keep reading the glossary

Previous entry: Countable additivity

Next entry: Covariance stationary

The book

Most learning materials found on this website are now available in a traditional textbook format.