Two sensors measure the same quantity, and the error of each sensor has variance . The total error has variance when the two errors are independent, when the second error always equals the first, and when it always equals the first with the sign reversed. The two separate variances cannot tell these cases apart, because the answer depends on how the errors move together. This lesson defines covariance, the summary that fills this gap, and correlation, its unit-free version, shows what each of them detects and what it misses, and derives the variance of sums and linear combinations.
Key terms
Covariance
Definition Let and be random variables on the same probability model with finite second moments, and . Then the means and are finite, and so is , because for all real and . The covariance of and is the expected product of their deviations from their means,
The second form comes from expanding the product and using linearity of expectation. Its subtracted term is the product of the two means, not the mean of the product. Covariance is symmetric, , and its unit is the product of the units of and . It can be positive, negative or zero. Positive covariance says that the centered products are positive on average, so the products from deviations with the same sign outweigh those from deviations with opposite signs.
In plain words On each outcome, multiply the deviation of from its mean by the deviation of from its mean, counting a deviation as negative when the value is below the mean, then average these products with the outcome probabilities. Deviations with the same sign push the average up, and deviations with opposite signs push it down.
Example In a constructed parcel model, marks an express parcel and an inspected one, and the pairs , , and have probabilities , , and . Then , and , so . The centered products in the four cells are , , and , and their weighted average agrees.
Uncorrelated variables
Definition Random variables and with finite second moments are uncorrelated if , or equivalently . Independent variables with finite second moments are uncorrelated. For discrete variables the product law turns the double sum for into the product of the sums for and . The converse is false. Uncorrelated variables can be dependent, even when one of them is a function of the other.
In plain words Zero covariance says that the positive and negative centered products cancel on average. It does not say that knowing one variable tells you nothing about the other. To show independence, check the joint distribution itself.
Example Let equal , or , each with probability , and let , so the pairs are , and . Then , and , so . The centered products are at , at and at , and they cancel. Yet is determined by , and the product law fails, since while .
Variance of a sum
Definition If and have finite second moments, then
with or without independence. The formula comes from expanding and taking expectations. For constants and the same expansion gives
so in particular . For variables with finite second moments,
The variances add exactly when the covariance terms add to . This holds when the variables are pairwise uncorrelated, and in particular when every two of them are independent.
In plain words The variance of a total is the sum of the separate variances plus a correction for how the parts move together. When the covariance terms add to a positive number, the total spreads more than the separate variances suggest, and when they add to a negative number, it spreads less.
Example For equal to , or with probability each and , the variances are and , and the covariance is , so . Directly, equals when is or , and when , so it is with probability and with probability . Its mean is , its second moment is and its variance is . The variances add here because the covariance is , even though the variables are dependent. In the parcel model , and the covariance is , so .
Bilinearity of covariance
Definition For random variables with finite second moments and constants , , and ,
and covariance distributes over sums in each argument, as in . Together with the symmetry , these rules say that covariance is linear in each argument when the other one is held fixed, which is what bilinear means. Added constants drop out because centering removes them, and for every constant . With the rules give , and expanding term by term gives the variance of a sum again.
In plain words Shifting a variable does not change how it moves with another one, rescaling it rescales the covariance by the same factor, and the covariance of a total with another variable is the sum of the covariances of its parts. Changing one variable from meters to centimeters multiplies its covariance with any other variable by .
Example For equal to , or with probability each, let . Bilinearity gives and . Directly, takes the values , and with probability each, so its mean is and its variance is .
Correlation coefficient
Definition Let and have finite second moments and positive variances. Their correlation coefficient is
It has no unit. For constants , , and , the correlation of and equals when and when , so a change of units with positive scale factors leaves it unchanged. If one of the variances is , that variable equals a constant with probability , its covariance with every variable is , and the correlation is undefined, because the formula divides by . Such a case is reported as undefined, not as zero correlation. Uncorrelated variables with positive variances have correlation .
In plain words Correlation is covariance measured in units of the two standard deviations, which makes the strength of a linear association comparable across problems with different scales. The next card shows that it always lies between and .
Example In the parcel model and , so
For equal to , or with probability each and , both variances are positive and the covariance is , so the correlation is although is a function of . If on every outcome, then , but the correlation of and is undefined.
Cauchy-Schwarz inequality
Definition For random variables and with finite second moments, the Cauchy-Schwarz inequality states
Applied to the centered variables and , it gives , so whenever the correlation is defined. A direct argument standardizes the variables. With , the variables and have mean , variance and , so
Perfect correlation means or . For and with positive variances, it happens exactly when with probability for constants and , with when and when . For example, forces , so with probability .
In plain words Correlation never exceeds in size, and it equals in size only when all of the probability lies on one straight line that is neither horizontal nor vertical. Perfect correlation is about a straight line. A curved exact relationship, such as in the three-point model, can have correlation .
Example For equal to , or with probability each and , the previous cards give , and . So and
For the covariance is and the correlation is . In the parcel model the inequality is strict, since while .
Check yourself
- A random variable has variance . Let and . Find , the correlation of and , and . Why is adding the two variances wrong here?
Show the answer
Bilinearity gives . The standard deviations are and , so the correlation is , as expected for . The sum is , whose variance is , and the formula agrees, since . Adding only the variances gives and leaves out the covariance term . Because , the two variables rise and fall together, and their covariance is , not . The mean of is not needed for any of this.
- Random variables and have , and correlation . Find , , and .
Show the answer
The covariance is . Then and . The negative covariance makes the sum less spread out and the difference more spread out. For the last one the constant drops out, and with and ,
- Let and have the joint probabilities , and . Find . Are and independent?
Show the answer
The mean of is , the mean of is , and
so . Both variances are positive, and , so the correlation is as well. The variables are still dependent. For instance , while . Given the value of is certainly , while given it is or . Zero covariance does not prove independence.