Tutorials › Introduction to Statistics › Why Expectation Is Linear

Random Variables and Expected Value · Tutorial 357 of 996

Why Expectation Is Linear

Learn how to derive and apply linearity of expectation, including when the random variables are dependent.

Intermediate 9 min read

What You'll Learn

  • Define expectation from a finite probability distribution and joint probability table.
  • Derive the formula for the expectation of a linear combination.
  • Explain why independence is not needed for linearity of expectation.
  • Find the expected value of a sum using the separate expectations.
  • Find and interpret the expected value of a difference in context.

Why Linearity Matters

When two random quantities are combined, it is natural to ask how their expected values are related. For example, if \(X\) counts arrivals in the morning and \(Y\) counts arrivals in the afternoon, the total is \(X+Y\). If each has a known expectation, can we find the expected total without first working out every possible combination of morning and afternoon counts?

For finite random variables, the answer is yes. The expectation of a sum is the sum of the expectations, and the expectation of a difference is the difference of the expectations. More generally, multiplying random variables by fixed constants and adding the results behaves in the same way. Importantly, these facts do not require the random variables to be independent.

Definition: If a random variable \(X\) takes finitely many values \(x\), with probabilities \(P(X=x)\), its expectation is $$ E(X)=\sum_x xP(X=x). $$ If \(X\) and \(Y\) are defined on the same experiment, their joint probability \(P(X=x,Y=y)\) describes the chance that they take the values \(x\) and \(y\) together.

The expectation is a probability-weighted average of the possible values. A joint probability table gives enough information to calculate expectations involving both \(X\) and \(Y\). The separate expectations, \(E(X)\) and \(E(Y)\), can also be obtained from the marginal probabilities: \(P(X=x)\) is the sum of the joint probabilities over all possible \(y\), and \(P(Y=y)\) is the corresponding sum over all possible \(x\).

The Linearity Rule

Suppose \(X\) and \(Y\) take finitely many values in the same experiment, and let \(a\) and \(b\) be fixed numbers. The expectation of \(aX+bY\) is calculated by taking the value \(ax+by\) for each joint outcome \((x,y)\), weighting it by that outcome's probability, and adding the results.

Theorem: For finite random variables \(X\) and \(Y\), and fixed constants \(a\) and \(b\), $$ E(aX+bY)=aE(X)+bE(Y). $$ No independence assumption is required.

Here is the derivation from the finite-sum definition. Write \(p(x,y)=P(X=x,Y=y)\). Summing over the possible pairs of values gives the expectation of the linear combination. The marginal probabilities are obtained by summing the joint probabilities across the other variable's possible values.

$$ \begin{aligned} E(aX+bY) &=\sum_x\sum_y (ax+by)p(x,y)\\ &=a\sum_x\sum_y xp(x,y)+b\sum_x\sum_y yp(x,y)\\ &=a\sum_x xP(X=x)+b\sum_y yP(Y=y)\\ &=aE(X)+bE(Y). \end{aligned} $$

The second line follows by distributing the sums and taking the fixed constants \(a\) and \(b\) outside them. In the third line, summing \(p(x,y)\) over all \(y\) gives \(P(X=x)\), while summing over all \(x\) gives \(P(Y=y)\). These steps use the joint probabilities' marginal totals, not any assumption about how \(X\) and \(Y\) relate.

In particular, setting \(a=b=1\) gives \(E(X+Y)=E(X)+E(Y)\). Setting \(a=1\) and \(b=-1\) gives \(E(X-Y)=E(X)-E(Y)\). A fixed constant can also be added: since a constant \(c\) has expectation \(c\), \(E(aX+bY+c)=aE(X)+bE(Y)+c\).

Worked Example: A Linear Combination of Dependent Variables

Worked Example: A Linear Combination of Dependent Variables

Consider a hypothetical experiment with two finite random variables \(X\) and \(Y\). Their joint probability table is:

\(X\)\(Y=0\)\(Y=2\)Row total
\(X=0\)0.200.300.50
\(X=1\)0.300.200.50
Column total0.500.501.00

Find \(E(3X-2Y+4)\). First calculate the two expectations from the row and column totals:

$$ E(X)=0(0.50)+1(0.50)=0.50,\qquad E(Y)=0(0.50)+2(0.50)=1.00. $$

The linearity rule gives:

$$ E(3X-2Y+4)=3E(X)-2E(Y)+4 =3(0.50)-2(1.00)+4=3.50. $$

A direct check uses the four joint outcomes. The values of \(3X-2Y+4\) are 4, 0, 7, and 3, respectively, for \((X,Y)=(0,0),(0,2),(1,0),(1,2)\). Therefore,

$$ 4(0.20)+0(0.30)+7(0.30)+3(0.20) =0.80+0+2.10+0.60=3.50. $$

These variables are not independent: for example, \(P(X=0,Y=0)=0.20\), whereas \(P(X=0)P(Y=0)=0.50(0.50)=0.25\). The calculation still works. In this example, as in the theorem, the joint probabilities need not factor into products of marginal probabilities.

Using Linearity to Find an Expected Sum

When two counts refer to parts of the same overall process, their sum is often the quantity of interest. If their individual probability distributions are known, the expected total can be found without constructing a joint probability table. This is useful even when the counts may be related.

Worked Example: Expected Arrivals Across Two Time Periods

In a hypothetical clinic, let \(X\) be the number of specimens arriving during a randomly selected morning and \(Y\) the number arriving that afternoon. Suppose the marginal probability distributions are as follows. The two counts are observed on the same day, but their joint distribution has not been supplied.

Morning count \(x\)\(P(X=x)\)Afternoon count \(y\)\(P(Y=y)\)
00.2500.20
10.5010.30
20.2520.50

The morning expectation is:

$$ E(X)=0(0.25)+1(0.50)+2(0.25)=1.00\text{ specimen}. $$

The afternoon expectation is:

$$ E(Y)=0(0.20)+1(0.30)+2(0.50)=1.30\text{ specimens}. $$

Let \(T=X+Y\) be the total number of specimens arriving that day. Linearity gives:

$$ E(T)=E(X+Y)=E(X)+E(Y)=1.00+1.30=2.30\text{ specimens}. $$

Thus the expected daily total is 2.30 specimens. The result does not say that 2.30 specimens must arrive on a particular day; a count is whole-numbered. It describes the probability-weighted average across repeated days under the stated distributions. No assumption about whether morning and afternoon counts are independent was needed.

Using Linearity to Find an Expected Difference

A difference can represent a signed comparison. For paired measurements, define \(D=X-Y\), so a positive value means \(X\) exceeds \(Y\), and a negative value means it is smaller. The expected difference is \(E(X)-E(Y)\), whether or not the two measurements vary together.

Worked Example: Expected Difference in Paired Waiting Times

In a hypothetical service comparison, a day is selected at random. Let \(X\) be the waiting time, in minutes, at desk A that day, and \(Y\) the waiting time at desk B on that same day. Suppose their marginal distributions are:

Desk A time \(x\), minutes\(P(X=x)\)Desk B time \(y\), minutes\(P(Y=y)\)
40.2530.50
80.5090.25
120.25150.25

Calculate each mean waiting time using its marginal distribution:

$$ E(X)=4(0.25)+8(0.50)+12(0.25)=1+4+3=8.00\text{ minutes}, $$ $$ E(Y)=3(0.50)+9(0.25)+15(0.25)=1.5+2.25+3.75=7.50\text{ minutes}. $$

For the paired difference \(D=X-Y\), linearity gives:

$$ E(D)=E(X-Y)=E(X)-E(Y)=8.00-7.50=0.50\text{ minutes}. $$

The expected paired difference is 0.50 minutes, with desk A's waiting time higher on average by that signed amount. This does not imply that desk A has a longer wait on every day, or that the difference is 0.50 minutes on a typical day. The marginal distributions do not tell us how often \(X>Y\), because that also depends on which desk times occur together.

What Linearity Does and Does Not Tell Us

Linearity determines the expectation of a sum, difference, or fixed linear combination from the separate expectations. It does not determine the full probability distribution of that combination. For example, knowing \(E(X)\) and \(E(Y)\) is enough to find \(E(X+Y)\), but not enough to calculate the probability that \(X+Y\) equals a particular value. Such a probability depends on how the possible values of \(X\) and \(Y\) occur together.

The distinction matters because expectation is a summary, not a description of every possible outcome. Two pairs of variables could have the same separate expectations and therefore the same expected sum, while having different joint patterns and different probabilities for particular sums. To answer questions about those probabilities, more than linearity is needed.

Key takeaway: For finite random variables on the same experiment, \(E(aX+bY)=aE(X)+bE(Y)\). The rule follows by distributing a finite sum over the joint probabilities. Independence is not required, but the joint behavior can still matter for questions about the distribution of the combined variable.

Common Mistake

A common incorrect argument is: “I can add the expected values only if \(X\) and \(Y\) are independent.” Independence is not a condition of linearity of expectation. The derivation distributes a sum over joint probabilities and then uses the marginal totals; it does not require those joint probabilities to factor. Dependence may affect which pairs of values occur, but it does not change the expected value of a sum once the separate expectations are fixed.

A related overreach is to use \(E(X+Y)=E(X)+E(Y)\) to claim that the distribution of \(X+Y\) can be found from the two expectations alone. That is not what the rule says. The rule gives one number, the expectation; the distribution of the sum requires information about possible values and their joint probabilities.

Check Your Understanding

Use the finite-sum definition and linearity to answer these questions.

  1. If \(E(X)=4\) and \(E(Y)=1.5\), find \(E(2X+3Y)\). State whether independence is needed.
  2. Suppose \(E(A)=12\) minutes and \(E(B)=9\) minutes. What is \(E(A-B)\), and how should its sign be interpreted?
  3. In a joint probability table, \(P(X=0,Y=0)=0.18\), while \(P(X=0)=0.40\) and \(P(Y=0)=0.50\). Does this pair of probabilities support independence? Does it prevent applying linearity?
  4. Explain why separate expectations are enough to find \(E(X+Y)\), but may not be enough to find \(P(X+Y=2)\).
  5. For a constant \(c\), explain why \(E(X+c)=E(X)+c\).