ContentsThe library

Chance, Spread and What to Expect

One Number Standing in for a Whole List

Last timeWeights on a List of Outcomes

Expectation collapses a distribution to a single number by weighting each outcome by how likely it is, and the two rules it obeys do most of the work in every later course.

A distribution is a whole list of numbers, and most of the time a single number

is wanted instead. If a request might take one millisecond or two hundred, what

is the time it takes? There is no honest single answer, but there is a standard

one, and it is the one every later course uses.

Take each possible value, multiply by the weight on it, and add.

FIG 1The definition, and it is a one line definition
the quantity in question, whose value is not yet known
the value it takes if the i-th outcome happens
the weight on that outcome
the expectation, read as the expected value of X
An average in which the likely outcomes count for more. If all the weights were equal this would reduce to the ordinary average everyone already knows, which is the special case; the general case simply lets some outcomes pull harder than others.

Apply that to the four outcome request from the previous lesson, with times of

one, eight, thirty and two hundred milliseconds and weights of ninety four,

four, one and a half, and a half hundredths. The sum comes to about two point

seven milliseconds. Two things about that number are worth noticing immediately.

The first is that it is not close to the common case. Ninety four percent of

requests take one millisecond, and the expectation is nearly three times that,

because the rare two hundred millisecond outcome contributes a full millisecond

all by itself despite happening once in two hundred times. Expectation is

sensitive to rare extremes, which is a feature when the extremes genuinely matter

and a trap when somebody reads the number as a description of a typical request.

The second is that two point seven is not a time any request takes. No outcome on

the list has that value.

FIG 2Where the expected time actually comes from
The four contributions to a total of 2.71 milliseconds. The rarest outcome supplies the largest share. This is not a pathology of the example; whenever the values span orders of magnitude, the expectation is dominated by the tail, and a reader who was told only the expectation has no way to know that.

It is a centre, not a forecast

The expectation of a fair six sided die is three and a half. The die has no face

showing three and a half and never will. The number is the balance point of the

distribution: if the weights were physical masses placed at the values along a

line, the expectation is where the line would balance.

That is worth holding onto because the word expected suggests a prediction, and

it is not one. The expected number of heads in three flips of a fair coin is one

and a half. The expected number of accidents at a junction next year might be

nought point seven. Neither is a possible outcome. What the expectation promises

is something about averages over many repetitions, which is the subject of a

later lesson in this course, and nothing at all about any single occasion.

The lesson stops here

4 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01A List, and a Number on Each Item
  2. 02One Number Standing in for a Whole Listyou are here
  3. 03The Second Number Every Average Needsopening only
  4. 04A Table Instead of a Listopening only
  5. 05What Is Left After the Newsopening only
  6. 06Four Times the Data for Half the Erroropening only
  7. 07Height Is Not Weightopening only
  8. 08The Number and the Bar Beside Itopening only

Read alongside