The variance of a random variable is a measure of how "spread out" its values tend to be. Specifically, it measures the average squared distance from the expected value (mean) of the distribution: \[\text{var}(X) = E\left(\left(X-E(X)\right)^2\right).\]

Consider drawing a card from a standard deck uniformly at random, and being paid based on the rank of the card, where aces are worth \(\$1,\) jacks are worth \(\$11,\) queens are worth \(\$12,\) and kings are worth \(\$13,\) and all other cards are worth the number appearing on them. What is the variance of the quantity of money you receive?

Covariance generalizes the concept of variance to multiple random variables. Instead of measuring the fluctuation of a single random variable, the covariance measures the fluctuation of two variables with each other. The covariance of random variables \( X \) and \( Y \) is defined as \[ \text{cov}(X, Y) = E\left((X - E(X))(Y - E(Y))\right). \] This can be expanded out as \[\text{cov}(X,Y)=E(XY)-E(X)E(Y).\]