Euler Hall — free maths guides

Compute the expectation of a discrete random variable

Compute an expectation from a mass function. The idea in plain words, a worked example, and a check with the answers shown — part of the free Statistics guides.

The balance point of a law

The expectation of a discrete variable is its probability-weighted average: E(X)=∑xx P(X=x).E(X)=\sum_x x\,P(X=x). Multiply each value by how likely it is, and add.

The word "average" misleads here in two ways. It is not the average of the values (that would weight each one equally, ignoring the law), and it need not be a value the variable can take — the mean of a fair die is3.53.5, which no roll produces. It is a balance point: put the values on a ruler with a weight at each equal to its probability, andE(X)E(X) is where it balances.

Two consequences that are used constantly:

  • - A constant is certain.E(c)=cE(c)=c for a constantcc; there is no variation to average out.
  • - A shift moves the mean.E(X+c)=E(X)+cE(X+c)=E(X)+c. Addingcc to every value addscc to the mean.

The expectation is a summary, not a description. Two laws can share a mean and be entirely different — one always near it, one wildly variable — which is why the variance is the next thing computed and never an optional extra.

Why weighting is the right operation

Over many independent repetitions, the running average of the observed values settles at the weighted average of the possible values, with the weights given by how often each occurs. That is the content of the law of large numbers, and it is why the expectation is the useful summary: it is the number the average is heading for.

Formally, group the repetitions by value. If valuexx occurs a proportionp(x)p(x) of the time, then the average of all observations is∑xx⋅(proportion of x)\sum_x x \cdot (\text{proportion of } x), which is∑xx p(x)\sum_x x\,p(x). That identity is exact for a finite sample and becomes a limit as the sample grows.

Note what it does NOT say. It says nothing about a single observation, and nothing about the spread. A lottery has a small positive expectation and a very large chance of losing; the expectation is the right number for an insurer pooling thousands of tickets and the wrong number for one player deciding tonight.

Worked example: two laws, two means

Law A.P(0)=0.1P(0)=0.1,P(1)=0.2P(1)=0.2,P(2)=0.4P(2)=0.4,P(3)=0.3P(3)=0.3. E(X)=0(0.1)+1(0.2)+2(0.4)+3(0.3)=0+0.2+0.8+0.9=1.9.E(X)=0(0.1)+1(0.2)+2(0.4)+3(0.3)=0+0.2+0.8+0.9=1.9.

Law B.P(1)=0.5P(1)=0.5,P(2)=0.3P(2)=0.3,P(3)=0.2P(3)=0.2. E(X)=1(0.5)+2(0.3)+3(0.2)=0.5+0.6+0.6=1.7.E(X)=1(0.5)+2(0.3)+3(0.2)=0.5+0.6+0.6=1.7.

Check against the plain average. The plain average of law A's values is(0+1+2+3)/4=1.5(0+1+2+3)/4=1.5, which is not1.91.9 — the values are not equally likely, so the plain average is the wrong number. That gap is the whole reason for weighting.

Check with a shift. If law B's values are each increased by 10, its mean becomes1.7+10=11.71.7+10=11.7 without recomputing the sum.

By the end you can
  • Compute an expectation from a mass function
  • Explain why the mean need not be an attainable value
  • Use the shift and scale rules for a mean
Check yourself
  1. 1.P(0)=0.2P(0)=0.2,P(5)=0.8P(5)=0.8. FindE(X)E(X).
  2. 2. The same law with 2 added to each value. Find the new mean.
  3. 3. Why is the plain average of the support the wrong answer in general?
Answers
  1. 1.0(0.2)+5(0.8)=40(0.2)+5(0.8)=4.
  2. 2.66.
  3. 3. Because it assumes every value is equally likely, which a mass function usually contradicts.
Work out where to start — free, no accountAnswer six real questions — free, no account