Tutorials › Exam P - Probability › Covariance With Constants and Self-Covariance

Exam P · Covariance and Correlation · Tutorial 756 of 915

Covariance With Constants and Self-Covariance

Use the covariance definition and product-moment identity to simplify constant and self-covariance calculations, and avoid common errors.

Intermediate 9 min read

What You'll Learn

  • Define covariance with a constant and covariance of a variable with itself.
  • Derive both identities from the centered definition and the product-moment identity.
  • Calculate self-covariance from a discrete distribution using moments.
  • Check a covariance result using centered deviations.
  • Recognize and correct a common error involving the expectation of a constant.

Why These Two Covariance Identities Matter

Covariance measures how two random variables vary together. In calculations, however, one or both entries in a covariance expression may not actually vary: a fixed fee, threshold, or benchmark is a constant, while an expression such as \(\operatorname{Cov}(X,X)\) uses the same random variable twice. Recognizing these cases can simplify a problem before any detailed calculation is needed.

This tutorial establishes two basic identities: covariance with a constant is zero, and a variable’s covariance with itself is its variance. It also shows how to verify the results numerically. The calculations assume the expectations involved exist; in particular, for self-covariance and variance, \(X\) must have a finite second moment.

Definition: For random variables \(X\) and \(Y\) with finite second moments, their covariance is $$ \operatorname{Cov}(X,Y)=E[(X-E[X])(Y-E[Y])]. $$ A constant \(c\) is a fixed number, not a random quantity that changes from outcome to outcome. Its expectation is \(E[c]=c\).

The product-moment identity, established in the earlier material on covariance, is

$$ \operatorname{Cov}(X,Y)=E[XY]-E[X]E[Y]. $$

Both forms are useful. The centered definition makes it clear what happens when a variable has no deviations from its mean. The product-moment identity often gives the quickest numerical calculation.

Covariance With a Constant

A constant has the same value in every outcome, so it has no variation with which another variable could move together. Algebraically, if \(c\) is fixed, then \(E[c]=c\), and the centered value of the constant is always zero.

Theorem: If \(X\) has a finite expectation and \(c\) is a constant, then $$ \operatorname{Cov}(X,c)=\operatorname{Cov}(c,X)=0. $$

Here is a short derivation using the centered definition. Since the mean of \(c\) is \(c\), its deviation from its mean is \(c-E[c]=0\) for every outcome. Therefore,

$$ \operatorname{Cov}(X,c) =E[(X-E[X])(c-E[c])] =E[(X-E[X])\cdot 0] =0. $$

The product-moment identity gives the same result:

$$ \operatorname{Cov}(X,c) =E[Xc]-E[X]E[c] =cE[X]-E[X]c =0. $$

The constant can be in either position. Covariance is symmetric, but the product-moment calculation also verifies the reverse order directly:

$$ \operatorname{Cov}(c,X) =E[cX]-E[c]E[X] =cE[X]-cE[X] =0. $$

Worked Example: A Random Payment and a Fixed Charge

In a hypothetical reimbursement model, a payment \(X\) is \(0\), \(2\), or \(5\) thousand dollars, with probabilities \(0.2\), \(0.5\), and \(0.3\), respectively. A separate administrative charge is fixed at \(4\) thousand dollars. Calculate the covariance of the payment with the charge in both orders.

Method. Treat the charge as the constant \(c=4\), and use the product-moment identity. The stated probabilities sum to \(0.2+0.5+0.3=1\), so they define a probability distribution.

First calculate the payment’s mean: $$ E[X]=0(0.2)+2(0.5)+5(0.3)=0+1+1.5=2.5. $$ The fixed charge has \(E[c]=4\). Also, $$ E[Xc]=E[4X]=4E[X]=4(2.5)=10. $$ Thus, $$ \operatorname{Cov}(X,c)=E[Xc]-E[X]E[c] =10-(2.5)(4)=10-10=0. $$ For the reverse order, $$ E[cX]=10,\qquad E[c]E[X]=(4)(2.5)=10, $$ so $$ \operatorname{Cov}(c,X)=10-10=0. $$ Check. In every outcome, \(c-E[c]=4-4=0\), so the centered covariance is also zero. The result does not depend on the payment probabilities: covariance with a fixed charge is zero for any payment distribution for which the covariance is defined.

Self-Covariance Is Variance

When the same variable appears in both positions, each outcome’s deviation from the first mean is multiplied by that very same deviation in the second position. The product is therefore a squared deviation, which is exactly what variance averages.

Theorem: If \(X\) has a finite second moment, then $$ \operatorname{Cov}(X,X)=\operatorname{Var}(X) =E[(X-E[X])^2] =E[X^2]-(E[X])^2. $$

To derive the first equality, set \(Y=X\) in the centered covariance definition:

$$ \operatorname{Cov}(X,X) =E[(X-E[X])(X-E[X])] =E[(X-E[X])^2] =\operatorname{Var}(X). $$

To obtain the moment form, expand the square and use linearity of expectation:

$$ \begin{aligned} E[(X-E[X])^2] &=E[X^2-2X E[X]+(E[X])^2]\\ &=E[X^2]-2E[X]E[X]+(E[X])^2\\ &=E[X^2]-(E[X])^2. \end{aligned} $$

In the second line, \(E[X]\) is a number, so it can be taken outside the expectation. This identity is useful when a distribution makes \(E[X]\) and \(E[X^2]\) easier to calculate than all the separate centered deviations.

Worked Example: Finding Self-Covariance From a Discrete Distribution

A hypothetical model assigns the random variable \(X\) the values \(-1\), \(1\), and \(4\), with probabilities \(0.25\), \(0.50\), and \(0.25\). Find \(\operatorname{Cov}(X,X)\) using moments, then check it using centered deviations.

Method. Compute \(E[X]\) and \(E[X^2]\), then apply the self-covariance identity. First check the probabilities: \(0.25+0.50+0.25=1\).

The mean is $$ E[X]=(-1)(0.25)+(1)(0.50)+(4)(0.25) =-0.25+0.50+1=1.25. $$ The second moment is $$ E[X^2]=(-1)^2(0.25)+(1)^2(0.50)+(4)^2(0.25) =0.25+0.50+4=4.75. $$ Therefore, $$ \operatorname{Cov}(X,X)=\operatorname{Var}(X) =4.75-(1.25)^2 =4.75-1.5625 =3.1875. $$ For a direct check, the three deviations from the mean are \(-2.25\), \(-0.25\), and \(2.75\). Their probability-weighted squared deviations are $$ (2.25)^2(0.25)+(0.25)^2(0.50)+(2.75)^2(0.25) =1.265625+0.03125+1.890625 =3.1875. $$ The two methods agree, so \(\operatorname{Cov}(X,X)=3.1875\).

Using the Identities in a Longer Calculation

Expressions can contain several covariance terms, including terms with constants and terms that repeat the same random variable. Simplify each term according to what is actually random. A fixed number contributes zero when paired with a random variable; a variable paired with itself contributes its variance. These reductions do not require the random variables in different terms to be independent.

Worked Example: Simplifying a Mixed Covariance Expression

In a hypothetical two-factor risk model, \(U\) and \(V\) are random indices. The distribution of \(V\) is \(P(V=-1)=0.2\), \(P(V=0)=0.5\), and \(P(V=2)=0.3\). Simplify and evaluate $$ 2\operatorname{Cov}(U,5)+\operatorname{Cov}(V,V)-\operatorname{Cov}(9,U). $$

Method. Apply the constant and self-covariance identities term by term. No distribution for \(U\) is needed because it appears only in covariances with constants.

Since \(5\) and \(9\) are constants, $$ \operatorname{Cov}(U,5)=0,\qquad \operatorname{Cov}(9,U)=0. $$ The remaining term is $$ \operatorname{Cov}(V,V)=\operatorname{Var}(V). $$ Calculate the first two moments of \(V\): $$ E[V]=(-1)(0.2)+(0)(0.5)+(2)(0.3) =-0.2+0+0.6=0.4, $$ and $$ E[V^2]=(-1)^2(0.2)+(0)^2(0.5)+(2)^2(0.3) =0.2+0+1.2=1.4. $$ Hence, $$ \operatorname{Var}(V)=1.4-(0.4)^2=1.4-0.16=1.24. $$ Substituting into the expression gives $$ 2(0)+1.24-0=1.24. $$ Check. The probabilities for \(V\) sum to \(0.2+0.5+0.3=1\), and the variance is positive. The calculation uses no assumption about dependence between \(U\) and \(V\); the two terms involving \(U\) vanish because their other entries are constants.

Common Mistake: Forgetting the Mean of the Constant

A frequent error is to use \(E[Xc]-E[X]\) for \(\operatorname{Cov}(X,c)\). That expression omits the factor \(E[c]\) from the product-moment identity. As a result, it may incorrectly produce a nonzero answer.

For the payment and fixed charge in the first example, the incorrect calculation would be $$ E[4X]-E[X]=10-2.5=7.5, $$ which is not a covariance calculation. The correct second term is \(E[X]E[4]\), not just \(E[X]\): $$ E[4X]-E[X]E[4]=10-(2.5)(4)=0. $$ Always write both expected-value factors in the product-moment identity before substituting numbers. In particular, use \(E[c]=c\), rather than treating the constant’s expectation as \(1\) or leaving it out.

Key takeaway: A constant has zero deviation from its mean, so its covariance with any suitable random variable is zero. A variable’s covariance with itself is the expected squared deviation from its mean, which is its variance.

Check Your Understanding

For each problem, identify whether the covariance term involves a constant or the same random variable twice, and then calculate as needed.

  1. A random variable \(X\) takes values \(1\) and \(3\) with probabilities \(0.4\) and \(0.6\). Find \(\operatorname{Cov}(X,7)\). (Answer: \(0\))
  2. A random variable \(Z\) takes values \(-2\), \(0\), and \(2\) with probabilities \(0.25\), \(0.50\), and \(0.25\). Find \(\operatorname{Cov}(Z,Z)\). (Answer: \(2\))
  3. A random variable \(W\) takes values \(0\), \(1\), and \(4\) with probabilities \(0.50\), \(0.25\), and \(0.25\). Find \(\operatorname{Cov}(W,W)\). (Answer: \(2.6875\))
  4. \(A\) takes values \(2\) and \(6\), each with probability \(0.5\), and \(B\) is the constant \(3\). Evaluate \(\operatorname{Cov}(A,B)+\operatorname{Cov}(B,B)\). (Answer: \(0\))
  5. A random variable \(R\) takes values \(1\), \(2\), and \(5\), with probabilities \(0.2\), \(0.5\), and \(0.3\). Evaluate \(\operatorname{Cov}(R,R)-\operatorname{Cov}(R,4)\). (Answer: \(2.41\))
Clinical Biostats