Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

Probability

Reason about uncertainty without fooling yourself: sample spaces, conditioning, Bayes, random variables, and the distributions that keep reappearing.

Measuring uncertainty

Uncertainty is not the same thing as ignorance, because some uncertain things are more uncertain than others, and that comparison is what a number is for. This lesson asks what such a number could possibly mean, gets two incompatible answers, and finds that both answers obey the same rules. Nothing here needs more than arithmetic and the algebra of the foundations course.

The rule that started it

The oldest working definition of probability is a ratio of counts. List every case the situation can produce, decide which of them count as the event you care about, and divide:

P(A)=number of cases favourable to Anumber of cases in total

Gerolamo Cardano wrote this down in his Liber de Ludo Aleae around 1564, sitting on the manuscript until it was printed in 1663, and Pierre-Simon Laplace made it the formal definition in 1812 with one crucial rider: the cases must be equally possible. With that rider the rule works. A fair die has six cases, one of which is a six, so P(six)=1/60.1667. Two dice have 6×6=36 cases, of which six sum to seven, so P(sum=7)=6/360.1667 as well, while only five sum to eight, giving 5/360.1389.

That last pair of numbers is already worth something, because it explains an observation gamblers had made for centuries without being able to justify: seven comes up more often than eight, even though both can be made in several ways. The counting has to be done over the 36 ordered pairs, not over the 21 unordered totals, and the whole history of early probability is people getting that distinction wrong.

Two games that differ by a hair

In 1654 Antoine Gombaud, who styled himself the Chevalier de Méré, put a complaint to Blaise Pascal. He made money betting that at least one six would appear in four rolls of a single die, and lost money betting that at least one double six would appear in twenty-four rolls of two dice. His reasoning said the two should be identical: one chance in six, four rolls, and one chance in thirty-six, twenty-four rolls, both giving four sixths of a certainty. His purse said otherwise.

The counting rule settles it, provided you count the failures rather than the successes. Four rolls of one die produce 64=1296 equally likely sequences, and 54=625 of them contain no six, so

P(at least one six)=1-6251296=67112960.5177

Twenty-four rolls of a pair produce 3624 sequences, of which 3524 avoid the double six, so

P(at least one double six)=1-(3536)240.4914

One game is a shade better than even and the other a shade worse. The gap is 0.0263, about one bet in thirty-eight, which is invisible over an evening and ruinous over a career. De Méré had played enough to feel a difference of two and a half percentage points. The correspondence between Pascal and Fermat that followed this question is where the subject begins.

Example. What is the probability of getting at least one six in five rolls of a fair die?

Count the failures. Each roll avoids a six in five of its six cases, and the rolls are laid out as a sequence, so 55=3125 of the 65=7776 sequences contain no six at all. The complement gives 1-3125/7776=4651/77760.5981.

Now you. What is the probability of getting at least one six in three rolls of a fair die?

Answer

1-(5/6)3=1-125/216=91/2160.4213, so three rolls is a losing bet and four rolls a winning one.

Where counting cases runs out

The classical rule has two faults, and neither is repairable from inside it.

The first is circularity. "Equally possible" means equally probable, so the definition of probability contains the word it is defining. For a die this is harmless, because the symmetry of a cube gives an independent reason to believe the six cases are interchangeable: relabel the faces and nothing physical changes. Away from manufactured symmetric objects the escape closes. A drawing pin tossed on a table lands point up or point down, which is two cases, and nobody believes the answer is 1/2. Nothing about the pin says the two cases are interchangeable, and the only way to find out is to throw it.

The second fault is that the rule is silent whenever the cases cannot be made symmetric at all. What is the probability that a particular patient survives five years, that a bridge design fails, that it rains tomorrow? There is no bag of equally possible cases to count. These are the questions people actually have, and the classical definition does not so much answer them badly as refuse to accept them.

So the counting rule is not a definition. It is a correct calculation for one special structure, a finite space of interchangeable outcomes, and the general notion has to come from somewhere else.

What the record actually shows

The obvious somewhere else is measurement. If the probability of heads is the fraction of heads in the long run, then the way to find it is to toss the coin many times. People have done exactly this. Georges-Louis Leclerc, Comte de Buffon, recorded 2048 heads in 4040 tosses. Karl Pearson recorded 12012 in 24000. The most careful record is John Kerrich's, made while interned in Denmark during the Second World War and published in 1946, and it is worth seeing in full because it shows two things at once.

TossesHeadsHeads minus half the tossesFraction heads
104-10.4000
10044-60.4400
1000502+20.5020
50002533+330.5066
100005067+670.5067

Read the third column and the coin looks worse and worse: Kerrich ends 67 heads clear of half, having been only 6 clear at a hundred tosses. Read the fourth and it looks better and better, closing on 0.5 from 0.44. Both columns are correct, and they are not in conflict. The absolute surplus of heads grows without limit while the surplus divided by the number of tosses shrinks towards nothing. Whichever of these you call "the coin settling down" determines what you think probability is, and the later lesson on the laws of large numbers gives the exact rate at which each happens.

The fatal difficulty with defining probability as the long-run fraction is in the phrase "long run". No finite record ever hands you a number: Kerrich's fraction was 0.5067, not 0.5, and another ten thousand tosses would have given a third value. To say the fraction tends to a limit is to make a claim no experiment can confirm, and worse, it is a claim that is not even guaranteed by the theory, since a fair coin can in principle give heads forever. Frequency tells you how to estimate a probability. It does not tell you what one is.

Example. Kerrich was 6 heads below half at a hundred tosses and 67 above at ten thousand. In which record was the coin behaving more like a fair one?

Compare fractions, not counts. At a hundred tosses the fraction was 44/100=0.44, which misses 0.5 by 0.06. At ten thousand it was 5067/10000=0.5067, missing by 0.0067, roughly nine times closer. The larger discrepancy in raw heads belongs to the far larger experiment, and it is the fraction that carries the information about the coin.

Now you. At one thousand tosses Kerrich had 502 heads. Give the fraction and its distance from 0.5, and say how it compares with the ten thousand toss figure.

Answer

502/1000=0.502, which misses 0.5 by 0.002, closer than the 0.0067 at ten thousand tosses. Convergence is not tidy: a fraction can drift back out again, and does.

Probability as a price

The third reading abandons repetition altogether. On this view a probability is a degree of belief, and it is measured the way beliefs have always been measured in practice, by what someone will bet. Frank Ramsey in 1926 and Bruno de Finetti in 1931 made this precise. If you regard a payout of one unit on event A as worth exactly p units to buy or to sell, then p is your probability for A.

This sounds like an invitation to say anything, and it is not, because inconsistent prices can be robbed. Bookmakers quote odds "against": at 3 to 1 against, a winning stake of 1 returns 4, which corresponds to a probability of 1/(3+1)=0.25. Suppose a race with three horses is priced at 2 to 1, 3 to 1 and 4 to 1 against. The implied probabilities are 1/3, 1/4 and 1/5, and they sum to 0.7833. Back all three, staking exactly those fractions of a unit. Whichever horse wins, the return is exactly 1, because 3×13=4×14=5×15=1. Total outlay 0.7833, guaranteed return 1, guaranteed profit 0.2167 per unit staked out, a return of 27.7 percent on money with no risk whatsoever.

A set of prices that permits this is called a Dutch book, and the theorem that Ramsey and de Finetti proved is that you are safe from one if and only if your prices lie between 0 and 1 and add to exactly 1 across a set of alternatives exactly one of which must happen. Coherence, not frequency, forces the arithmetic. Real bookmakers make the sum exceed 1 on purpose, and the excess is their margin.

Example. A market prices three outcomes at evens (1 to 1), 5 to 1 and 9 to 1 against. Is it coherent, and if not, what is the risk-free return?

The implied probabilities are 1/2, 1/6 and 1/10, summing to 0.7667, which is less than 1, so the market is incoherent in the punter's favour. Staking 0.5, 0.1667 and 0.1 returns exactly 1 whichever outcome occurs, for an outlay of 0.7667: a profit of 0.2333 per unit returned, which is 30.4 percent on the money staked.

Now you. A two-outcome market is priced at 2 to 1 against on each side. What do the implied probabilities sum to, and who can be robbed?

Answer

Each price implies 1/3, so the sum is 2/3. Staking 1/3 on each costs 0.6667 and returns 1 for certain, a guaranteed profit of 0.3333, so the bookmaker is the one being robbed.

What both readings share

The frequentist reads a probability as a fact about a repeatable setup, and refuses to assign one to a unique event. The Bayesian reads it as a coherent price, and assigns one to anything. They disagree about what the number means, and about which questions are legitimate. They do not disagree about the arithmetic, and this is the fact the rest of the subject is built on.

Both give every probability a value in [0,1], because a fraction of a total cannot be negative or exceed the whole, and a price outside that range is a Dutch book in one line. Both make the probabilities of a set of mutually exclusive alternatives, one of which must occur, sum to exactly 1: the counting rule because the favourable cases partition the total, the betting rule because coherence demands it. Both make the probability of "A or B" equal to the sum of the separate probabilities when A and B cannot both happen, since disjoint sets of cases add and so do the stakes that cover them.

That is three rules, and they were reached three times over from unrelated starting points. Andrey Kolmogorov's move in 1933 was to stop asking what probability is and take those three statements as axioms, with everything else to be proved from them. It is the same move that made group theory out of symmetry and metric spaces out of distance, and it is why probability became a branch of mathematics rather than a collection of gambling results.

What is still missing

Taking the rules as axioms leaves an obvious gap. Rules have to be rules about something, and every statement above quietly assumed a background list: the six faces, the 1296 sequences, the three horses. "The probability of A or B" only means anything once A and B are the kind of object that can be combined with "or" at all.

So the first construction the subject needs is not a formula but a set: the collection of everything that could happen, with events living inside it as subsets, and "or", "and" and "not" becoming union, intersection and complement. That is the next lesson, and it turns the three rules above into three axioms with enough structure that real theorems follow from them.

Outcomes and events

Three rules survived the previous lesson: probabilities lie between zero and one, the alternatives sum to one, and disjoint alternatives add. Rules need something to be rules about, and this lesson builds it. The construction is set theory of the plainest kind, and by the end of it a handful of genuinely useful formulas will have been proved rather than asserted.

The list of everything that can happen

Start with the experiment, meaning any procedure with an uncertain result. Its sample space Ω is the set of all its possible outcomes, chosen so that exactly one of them occurs on each run: no two can happen together, and none can be left out.

For one roll of a die, Ω={1,2,3,4,5,6}. For two dice distinguished by colour, Ω is the set of ordered pairs (i,j), so it has 36 elements. That choice is not forced, and the alternative is instructive: you could take Ω to be the 11 possible totals, from 2 to 12, and the definition would still be satisfied, since exactly one total occurs. What you lose is symmetry. The 36 pairs are interchangeable and the 11 totals are not, so only the first choice lets you count. Choosing a sample space fine enough to be symmetric is the single most useful habit in the subject.

Sample spaces need not be finite. Toss a coin until the first head appears and record how many tosses it took: Ω={1,2,3,}, countably infinite, with no upper bound on how long you might wait. Measure the lifetime of a light bulb in hours and Ω is the set of non-negative real numbers, uncountable. All three kinds appear in this course.

An event is a subset of Ω: any collection of outcomes you might want to speak about as a unit. "The die shows an even number" is the subset {2,4,6}. "The two dice total seven" is a subset of six pairs. An event occurs when the outcome that happened is one of its members. Individual outcomes give the one-element events, Ω itself is the certain event, and the empty set is the impossible one.

Or, and, not

Putting events in a set makes ordinary logical words into set operations, and this is the whole reason for the construction.

"A or B", meaning at least one of them, is the union AB. "A and B", meaning both, is the intersection AB. "Not A" is the complement Ac=ΩA. Two events with AB= cannot both occur and are called disjoint or mutually exclusive. A family of events that are pairwise disjoint and whose union is all of Ω is a partition: exactly one of them happens.

Set algebra now supplies identities for free, including the two of De Morgan:

(AB)c=AcBc,(AB)c=AcBc

Read in words, the first says that "neither happened" is the same statement as "not the first and not the second", and the second says that "they did not both happen" is the same as "at least one failed to". These are not probability facts, they are facts about sets, and they will convert several awkward calculations into easy ones. The trick that solved de Méré's dice problem in the previous lesson was exactly the first identity: "at least one six" is the complement of "no sixes", and the second is far easier to count.

Three axioms

Kolmogorov's 1933 axioms assign to each event A a number P(A) subject to three demands.

P(A)0for every event A
P(Ω)=1
P(A1A2)=P(A1)+P(A2)+for pairwise disjoint Ai

The third is countable additivity, and the word countable is doing real work: it holds for infinite sequences of disjoint events, not merely for finitely many. That extension is what allows the coin-until-heads space to be handled, where the probabilities 1/2,1/4,1/8, must sum to 1 over infinitely many outcomes, which they do by the geometric series.

One honest caveat. On an uncountable sample space, such as a dart landing anywhere on a metre rule, it is not possible to assign a sensible probability to every subset: there are subsets so pathological that any assignment contradicts the axioms. The repair is to declare in advance a family of subsets that count as events, closed under complement and countable union, and demand nothing about the rest. That family is called a σ-algebra, and for everything in this course it can be ignored, because every set anyone would write down is in it. It is mentioned here only so that the word is not a surprise elsewhere.

What follows at once

Everything below is proved from the three axioms and nothing else.

The complement rule comes first. A and Ac are disjoint and their union is Ω, so P(A)+P(Ac)=P(Ω)=1, giving

P(Ac)=1-P(A)

Take A=Ω and this gives P()=0: the impossible event has probability zero. The converse fails, and it will matter later. An event of probability zero need not be impossible, as the lesson on continuous variables shows.

Next, if AB, split B into the disjoint pieces A and BA. Then P(B)=P(A)+P(BA), and since the last term cannot be negative,

ABP(A)P(B)

so probability is monotone. Combined with P(Ω)=1 this bounds every probability above by one, which the axioms never stated directly. The rearrangement P(BA)=P(B)-P(A) is the difference rule, valid when A sits inside B and not otherwise.

Example. In a group, 70 percent own a bicycle and 40 percent own a bicycle and a car. What can be said about the percentage owning a bicycle but no car?

"Bicycle and car" is a subset of "bicycle", so the difference rule applies exactly: P(bicycle,no car)=0.70-0.40=0.30. Note that nothing was assumed about how the two ownerships relate. The subset relation did all the work.

Now you. In the same group, 55 percent own a car. What percentage own a car but no bicycle?

Answer

0.55-0.40=0.15, again by the difference rule, since car-and-bicycle is a subset of car.

Adding events that overlap

The third axiom adds probabilities only for disjoint events, and most interesting pairs overlap. Fix it by splitting.

Write AB as the two disjoint pieces A and B(AB). Additivity gives P(AB)=P(A)+P(B(AB)), and since ABB the difference rule turns the second term into P(B)-P(AB). Hence

P(AB)=P(A)+P(B)-P(AB)

This is inclusion and exclusion. The subtraction is bookkeeping: adding the two probabilities counts the overlap twice, so it comes off once. For three events the same argument, applied twice, gives

P(ABC)=P(A)+P(B)+P(C)-P(AB)-P(AC)-P(BC)+P(ABC)

The pattern continues, alternating in sign, with all singles added, all pairs subtracted, all triples added, and so on.

Dropping the subtractions leaves an inequality that holds always, since the terms removed are non-negative:

P(A1A2An)P(A1)+P(A2)++P(An)

This is the union bound, or Boole's inequality. It is crude, it needs no information at all about how the events relate, and it is used constantly, because "at least one of these bad things happens" is bounded by the sum of the individual risks whether or not they are connected. When the sum exceeds one it says nothing, which is the honest signal that the events overlap too much for it to help.

Example. A whole number is drawn at random from 1 to 1000, each equally likely. What is the probability it is divisible by 2, by 3 or by 5?

Count each set: 500 multiples of 2, 333 of 3, 200 of 5. Subtract the pairs, counted by the least common multiples: 166 multiples of 6, 100 of 10, 66 of 15. Add back the 33 multiples of 30. The union has

500+333+200-166-100-66+33=734

members, so the probability is 0.734. The union bound would have offered only (500+333+200)/1000=1.033, which is no information at all.

Now you. Two fair dice are rolled. Let A be "at least one die shows a five", which contains 11 of the 36 pairs, and B be "the total is eight", which contains 5. Their intersection contains 2. Find P(AB).

Answer

P(AB)=11/36+5/36-2/36=14/360.3889.

When the outcomes are equally likely

Suppose Ω is finite with N outcomes and all of them carry the same probability p. Additivity over the N one-element events gives Np=P(Ω)=1, so p=1/N, and for any event A containing |A| outcomes,

P(A)=|A|N

The classical rule of the previous lesson is recovered, no longer as a definition but as a theorem about one particular assignment among many. The axioms are silent about whether the outcomes deserve equal probability; that is a modelling decision made outside the mathematics, justified by symmetry when there is symmetry and by measurement when there is not.

Nothing forces uniformity. A loaded die might carry P(6)=0.25 with the other five faces sharing the remaining 0.75 equally, at 0.15 each, and every rule above still applies unchanged. The infinite space is the sharper case: for the coin tossed until the first head, P(n)=2-n, which sums to 1 but assigns different probabilities to different outcomes, and no uniform assignment on {1,2,3,} is even possible, since equal positive values summing to one over infinitely many outcomes cannot exist.

Example. A die is loaded so that P(6)=0.25 and the other five faces are equally likely. What is the probability of an even number?

The other five faces share 1-0.25=0.75, so each has 0.15. The even faces are 2, 4 and 6, disjoint one-element events, so P(even)=0.15+0.15+0.25=0.55. On a fair die it would be 0.5, and the loading has shifted it.

Now you. For the same loaded die, find the probability that the result is at least 4.

Answer

The outcomes 4, 5 and 6 have probabilities 0.15, 0.15 and 0.25, so the answer is 0.55 as well. The two events differ but happen to share a probability.

What the axioms do not give you

Three axioms and some set algebra have produced the complement rule, monotonicity, the difference rule, inclusion and exclusion in any number of events, and the union bound. That is a working toolkit, and it is worth being clear about what it is not.

The axioms never say what number to attach to any particular event. They constrain assignments to be consistent with one another; they cannot manufacture one out of nothing. Every calculation in this lesson began from probabilities that were either handed over or justified by a symmetry argument outside the theory, and this is not a defect to be repaired later. It is the permanent division of labour: modelling supplies the inputs, the axioms police the consequences.

The other gap is practical. Once symmetry does apply, P(A)=|A|/N reduces every question to two counts, and the sets that arise are rarely small enough to list. How many five-card hands contain two pairs? How many ways can twenty-three birthdays fall so that no two coincide? Answering questions like these is a discipline of its own, and it is the subject of the next lesson.

Counting the possibilities

When outcomes are equally likely, a probability is a ratio of two counts, and the counts are rarely small enough to list. This lesson builds the three tools that do the counting, checks them against a deck of cards, and then uses them on a question whose true answer almost nobody guesses within a factor of two.

Choices in sequence

Everything here rests on one observation. If a first choice can be made in a ways and, for each of those, a second in b ways, then the pair can be made in ab ways. Lay the possibilities out as a rectangular grid with a rows and b columns and the claim is just the area of a rectangle. Extend to any number of stages and it becomes the product rule: multiply the number of options at each stage, provided the number of options at each stage does not depend on which options were taken earlier.

That proviso is the whole art. Two dice give 6×6=36 sequences because the second die does not care what the first did. A four-character password from the 26 lowercase letters gives 264=456976, again because letters may repeat. But drawing two cards from a deck gives 52×51=2652 ordered pairs, not 522, because the second draw has one fewer option: the count at each stage changed, though crucially it changed by the same amount regardless of which card went first, and that is enough for the rule to apply.

Sampling with replacement leaves the pool intact and gives nk sequences of length k. Sampling without replacement shrinks it and gives n(n-1)(n-2)(n-k+1), a product of k falling terms. When k=n the second product uses up the whole pool and is written n!, read "n factorial", with 0!=1 by the convention that there is exactly one way to arrange nothing.

Ordered selections

The falling product has a name. The number of permutations of k items chosen from n distinct items, where order matters and nothing is reused, is

P(n,k)=n(n-1)(n-k+1)=n!(n-k)!

The second form is the first with the unused tail (n-k)! divided away, which is often the easier thing to compute. The five-card deal from a shuffled deck, if you insist on tracking the order they arrived in, gives P(52,5)=52×51×50×49×48=311875200 possibilities.

Repeated items collapse the count. The letters of MISSISSIPPI can be arranged in 11! ways if the letters are all treated as distinct, but the four S's are not distinguishable, so every genuine arrangement has been counted 4! times over on their account, and likewise 4! for the I's and 2! for the P's. Divide those out:

11!4!4!2!1!=34650

That division, cancelling the orderings you did not want to distinguish, is the single most useful move in combinatorics, and the next section is nothing but the same move applied once.

Unordered selections

A poker hand is a set of five cards, and the order it was dealt in is nobody's business. Each such set of five was counted 5! times among the 311875200 ordered deals, once for each arrangement of the same five cards. So the number of distinct hands is that figure divided by 5!=120, giving 2598960.

In general the number of ways to choose k items from n when order is irrelevant is written C(n,k), read "n choose k", and

C(n,k)=P(n,k)k!=n!k!(n-k)!

Two properties are worth carrying. First, C(n,k)=C(n,n-k), because choosing which k to take is the same act as choosing which n-k to leave. Second, C(n,k)=C(n-1,k-1)+C(n-1,k): fix any one item, and every selection either includes it, which leaves k-1 to pick from the other n-1, or excludes it, which leaves k to pick from the other n-1. That identity generates Pascal's triangle row by row, and it will return in the lesson on the binomial distribution.

Example. A lottery draws 6 numbered balls from 49, order irrelevant. What is the probability that one particular ticket matches all six?

The number of possible draws is C(49,6)=49!/(6!43!)=13983816, and exactly one is the ticket, so the probability is 1/139838167.15×10-8. Buying one ticket a week, the expected wait for a win is about 269000 years.

Now you. How many ways are there to choose a committee of 3 people from a group of 10, and what is the probability that a randomly chosen committee contains one particular person?

Answer

C(10,3)=120 committees. Those containing the given person are the committees made by adding two others from the remaining nine, so there are C(9,2)=36, and the probability is 36/120=0.3. Equivalently, the person occupies one of 10 places and 3 are taken, so 3/10.

Poker as a test bench

A ranked list of poker hands is a good check on the machinery, because the ranking was fixed by players long before anyone computed it, and the counts must come out in the same order.

Take two pair. Choose the two ranks that will be paired: C(13,2)=78 ways. Choose two suits for each of them: C(4,2)=6 ways each, so 36. The fifth card must avoid both chosen ranks, leaving 52-8=44 cards. That gives 78×36×44=123552 hands, and

P(two pair)=12355225989600.0475

Note the order of the two ranks was never used, which is why C(13,2) and not 13×12 appears. Choosing "kings and threes" is the same hand as choosing "threes and kings", and counting it twice would double the answer.

Now a flush. Choose a suit, 4 ways, then any five of its 13 cards, C(13,5)=1287 ways, giving 5148. Of those, 40 are also straights and are ranked higher, so a plain flush has 5108 hands and probability 5108/25989600.0020. Two pair is about 24 times commoner than a flush, and duly ranks below it. The same method gives 3744 full houses (0.0014) and 624 four-of-a-kinds (0.00024), and the ranking players arrived at by experience is exactly the ranking these counts produce.

Example. How many five-card hands are three of a kind, meaning exactly three cards of one rank and two other cards of two different ranks?

Pick the tripled rank in 13 ways and its three suits in C(4,3)=4 ways. The other two cards must be of two distinct ranks, neither equal to the first: C(12,2)=66 choices of ranks, and 4×4=16 choices of suit. That gives 13×4×66×16=54912 hands, a probability of about 0.0211.

Now you. How many five-card hands contain exactly one pair, meaning two cards of one rank and three others of three different ranks?

Answer

13×C(4,2)×C(12,3)×43=13×6×220×64=1098240 hands, a probability of about 0.4226. Nearly half of all hands, which is why one pair is worth almost nothing.

The birthday problem

Take 23 people at random. What is the probability that two of them share a birthday? The usual guess is a few percent, on the grounds that 23 is small next to 365. The right answer is slightly over one half.

Count the complement, as always. Ignore leap years and assume all 365 days equally likely, an assumption examined below. Sequences of 23 birthdays number 36523, all equally likely. Those with no repeat are ordered selections without replacement, 365×364××343, so

P(no shared birthday)=365365×364365××3433650.4927

and the probability of at least one shared birthday is 1-0.4927=0.5073.

The reason intuition fails is that people compare 23 with 365, when the right comparison is with the number of pairs. Twenty-three people form C(23,2)=253 pairs, and 253 against 365 no longer looks small. Each pair matches with probability 1/365, so the union bound of the previous lesson caps the answer at 253/3650.693, which is loose but already in the right neighbourhood, and it is loose in the right direction: the pairs overlap heavily, since any three people share three pairs among them.

The curve climbs fast. Ten people give 0.117, thirty give 0.706, fifty give 0.970. The real-world assumption of uniform birthdays is not quite true, with seasonal peaks and a deficit around late December in many countries, but the effect only ever pushes the probability up, since any unevenness makes coincidences commoner. The 23 figure is therefore a safe upper bound on the number of people needed.

Example. What is the probability that among 10 people at least two share a birthday?

Multiply the falling ratios: P(no match)=k=09(365-k)/3650.8831, so the answer is 1-0.8831=0.1169, about one chance in nine. Small, but far larger than the 10/3650.027 that a careless comparison suggests.

Now you. Four fair dice are rolled. What is the probability that at least two show the same number?

Answer

The same structure with 6 in place of 365: P(all different)=(6×5×4×3)/64=360/12960.2778, so at least one repeat has probability 0.7222.

What counting assumes, and when it stops working

Every calculation above began by declaring a set of equally likely outcomes and then measuring a subset of it. That is a strong assumption, and it is doing more work than the algebra. If the deck is not well shuffled, or the birthdays are not uniform, or the lottery machine favours a ball, the counts are still right and the probabilities are wrong. Counting is a technique for evaluating a model, not evidence that the model is correct.

There is a second and sharper limit. The whole method treats the sample space as intact: all 2598960 hands are live, all 36523 birthday sequences are live. The moment any information arrives, most of them are not. Told that the first two cards dealt are aces, the remaining possibilities are a much smaller set, and the probability of four of a kind is no longer 0.00024. Told that one person in the room was born in March, the birthday calculation changes.

Recounting from scratch after every piece of news is unworkable, and it is also unnecessary, because the effect of information on a probability follows one rule that can be derived once. Deriving it, and finding that it makes independence into a definition rather than a feeling, is the next lesson.

Conditional probability

Every probability computed so far assumed the whole sample space was still in play, and information destroys that assumption. This lesson derives the one rule that says what a probability becomes once something is known, and then uses it to define independence, to build trees, and to settle a game show argument that split a magazine's readership in 1990.

Renormalising onto what is left

Two fair dice are rolled and you are told the total is at least nine. What is the probability that at least one die shows a six?

The original sample space had 36 equally likely pairs. The news has killed every pair whose total is eight or less, leaving 10 pairs, and those 10 are still equally likely relative to one another, because nothing distinguished them before and the news treated them alike. Of the survivors, 7 contain a six. So the answer is 7/10=0.7, against an unconditional 11/360.306.

Two things happened. The sample space shrank to the event that was reported, and the probabilities of the survivors were scaled up so they again sum to one. That scaling is a division by the probability of the reported event, and writing it in general gives the definition. For events A and B with P(B)>0,

P(A|B)=P(AB)P(B)

read "the probability of A given B". The numerator keeps only the part of A that survives, and the denominator is the renormalisation. Check it on the dice: P(AB)=7/36, P(B)=10/36, and the ratio is 7/10.

This is a definition rather than a theorem, but it is not arbitrary. For any fixed B, the assignment AP(A|B) satisfies all three of Kolmogorov's axioms: it is non-negative, it gives Ω probability P(B)/P(B)=1, and it is additive because the numerator is. So a conditional probability is a probability, and every rule from the earlier lesson holds inside it, including P(Ac|B)=1-P(A|B). What is not true, and is a standard error, is that anything holds when you condition on different things: P(A|B)+P(A|Bc) is not 1 and need not be anything in particular.

The chain rule

Multiply the definition out and it becomes a way to build probabilities rather than to update them:

P(AB)=P(B)P(A|B)

and iterating, for three events,

P(ABC)=P(A)P(B|A)P(C|AB)

This is how sequential experiments are actually computed. Draw two cards from a full deck: the first is an ace with probability 4/52, and given that, the second is an ace with probability 3/51, since one ace and one card are gone. So

P(two aces)=452×351=1226520.004525

Three aces adds a factor 2/50 and gives 0.000181. The counting lesson would reach the same answers through C(4,2)/C(52,2), and the chain rule is usually quicker because each factor is a small local question.

The same pattern handles any sequential draw. An urn holding 5 red and 3 black balls gives up two reds in a row with probability (5/8)(4/7)=20/560.3571, and two blacks with probability (3/8)(2/7)=6/560.1071, each factor asking only what is left in the urn at that moment.

Independence, defined rather than felt

Sometimes the news changes nothing: P(A|B)=P(A). Substituting into the chain rule turns this into a symmetric statement with no division in it, and that is the form to take as the definition. Events A and B are independent when

P(AB)=P(A)P(B)

The symmetry is worth noticing. If B tells you nothing about A then A tells you nothing about B, which is not obvious from the conditional form but is immediate from this one. The definition also handles the awkward case P(B)=0, where the conditional is undefined but the product form is fine.

Independent is not the same as disjoint, and confusing them is the commonest slip in the subject. Disjoint events are maximally dependent: if A and B cannot both happen, then learning B occurred tells you A certainly did not, so P(A|B)=0. Two disjoint events of positive probability are never independent.

Independence is also not settled by checking pairs. Roll two fair dice and take A as "first die is even", B as "second die is even", C as "the total is even". Each has probability 1/2, and each pair is independent: knowing the first die is even says nothing about the second, and knowing the second die is even leaves the total even exactly when the first is, still probability 1/2. But the three together are not independent, because any two of them force the third, so P(ABC)=P(AB)=1/4, not (1/2)3=1/8. Full independence of a family means every subfamily multiplies, not merely every pair.

In practice independence is an assumption imported from the physics of the situation, not something read off the numbers. Successive coin tosses are independent because a coin has no memory. Successive days of rain are not. Assuming independence where it does not hold is how risk models fail, since it makes simultaneous disasters look astronomically unlikely when they are merely unlikely.

Example. A component fails during a mission with probability 0.02, independently of the other components. A system contains four such components and works only if all four survive. What is the probability that the system works?

Independence lets the probabilities multiply: P(all survive)=0.9840.9224, so the system fails with probability about 0.0776, nearly four times the single-component risk.

Now you. The same system is built with six such components instead of four. What is the probability that it works?

Answer

0.9860.8858, so the failure probability rises to about 0.1142.

The law of total probability

Conditioning is most useful when the conditioning events form a partition: a set of alternatives B1,B2,,Bn, exactly one of which occurs. Any event A is then chopped into the disjoint pieces ABi, and additivity plus the chain rule gives

P(A)=iP(Bi)P(A|Bi)

the law of total probability. Read it as an instruction: split the world into cases, work out the answer within each case, and average the answers weighted by how likely each case is.

Take a factory with three machines. Machine one makes 50 percent of the output with a defect rate of 1 percent, machine two makes 30 percent at 2 percent, machine three makes 20 percent at 3 percent. An item is picked at random from the day's production. Then

P(defective)=0.5(0.01)+0.3(0.02)+0.2(0.03)=0.005+0.006+0.006=0.017

so 1.7 percent overall, which lies between the best and worst machine rates and is nearer the best, because the best machine makes the most. Note what the calculation does not answer: given that an item is defective, which machine most likely made it? Machine one contributes the largest single share of the defects, 0.005 out of 0.017, or 29.4 percent, despite having the lowest defect rate, simply because it makes half of everything. That reversal is the subject of the next lesson.

Example. From the urn of 5 red and 3 black balls, two are drawn without replacement. What is the probability that the second is red?

Condition on the first. If the first was red (probability 5/8), four of the remaining seven are red. If it was black (probability 3/8), five of seven are. So

P(second red)=5847+3857=20+1556=3556=0.625

which is exactly 5/8, the probability the first is red. This is not a coincidence: before you look at anything, the ball in position two is as likely to be red as the ball in position one, because the balls were never ordered by colour. Symmetry gives the answer in one line where conditioning takes three.

Now you. A box holds 4 white and 6 green counters. Two are drawn without replacement. Use the law of total probability to find the probability that the second is white, and check it against the symmetry argument.

Answer

41039+61049=12+2490=3690=0.4, which is 4/10 as symmetry predicts.

The three doors

In September 1990 Marilyn vos Savant answered a reader's question in Parade magazine and received thousands of letters telling her she was wrong, many from people with doctorates. The setup: three doors, a car behind one and goats behind the other two. You pick a door. The host, who knows where the car is, opens one of the other two to reveal a goat, and always can. He offers you the switch. Should you take it?

The answer is yes, and switching wins with probability 2/3. The clean way to see it is to condition on your first pick, which is the only random thing you control. With probability 1/3 your first pick was the car, in which case switching loses. With probability 2/3 it was a goat, in which case the host is forced to reveal the other goat, so the remaining door holds the car and switching wins. There are no other cases, so switching wins with probability 2/3 and staying with probability 1/3.

The reason the wrong answer is so seductive is that the host's action feels like it leaves two equally likely doors. It does not, because the host's choice is not random: he never opens the car, and he never opens your door. Those two constraints leak information about where the car is, and the leak flows entirely to the door he did not open. Change the rules so the host opens a door at random and happens to reveal a goat, and the two remaining doors really are equally likely, and switching gains nothing. The puzzle is a lesson about conditioning on what actually happened, including on the rule that generated it.

Example. The same game with 100 doors: you pick one, and the host opens 98 others, all goats, always able to. What is the probability that switching wins?

Your first pick is the car with probability 1/100. Otherwise, with probability 99/100, the single door the host left closed is the car, since he was forced to leave it. Switching wins with probability 0.99.

Now you. The game with 5 doors: you pick one, the host opens 3 others, all goats. What is the probability that switching to the one remaining door wins?

Answer

Your pick is right with probability 1/5, so switching wins with probability 4/5=0.8.

The direction of the arrow

Conditioning has given a definition, a chain rule for building sequences, a real test for independence, and a way to average over cases. Every one of those runs the same way: from a cause, or an earlier stage, to what is observed. The factory calculation went from machine to defect. The urn went from first draw to second. The doors went from where the car was to what the host did.

Real questions run backwards. The defect is on the bench and the machine is unknown. The test result is positive and the disease is unknown. The evidence is in the courtroom and the guilt is unknown. What is wanted is P(cause|observation), and what is easy to state is P(observation|cause), since the second is a property of the mechanism and the first is not.

Nothing new is needed to reverse them, because the definition of conditional probability is already symmetric in a way that has not been exploited: P(AB) can be expanded in two orders. Setting the two expansions equal gives the most consequential single formula in the subject, and it is the next lesson.

Bayes' theorem

The conditional probabilities that are easy to state run from cause to observation, and the ones people actually want run the other way. This lesson derives the formula that turns one into the other, applies it to a real screening test where the honest answer is startling, and shows why the result is so consistently misjudged, including by the professionals who depend on it.

Turning the conditional around

The previous lesson defined P(A|B)=P(AB)/P(B), and the intersection can be expanded in either order:

P(AB)=P(B)P(A|B)=P(A)P(B|A)

Set the two right-hand sides equal and divide by P(B), which is legitimate whenever P(B)>0:

P(A|B)=P(A)P(B|A)P(B)

That is Bayes' theorem, published posthumously in 1763 from an essay by Thomas Bayes and given its general form by Laplace in 1774. The derivation is two lines of algebra with no new assumption, which is worth stressing: nothing about the theorem is contentious. What is contentious is what people are willing to put into it.

The names for the pieces carry the meaning. Write H for a hypothesis and E for the evidence. Then P(H) is the prior, what the hypothesis was worth before the evidence; P(E|H) is the likelihood, how well the hypothesis predicts the evidence; P(E) is the probability of the evidence under all hypotheses together; and P(H|E) is the posterior, what the hypothesis is worth after. The denominator is almost never given directly and is nearly always computed by the law of total probability. With two hypotheses, H and its negation,

P(H|E)=P(H)P(E|H)P(H)P(E|H)+P(Hc)P(E|Hc)

Every term on the right has an operational meaning, and the third one, P(E|Hc), the chance of the same evidence when the hypothesis is false, is the term that gets left out when people reason informally. Evidence that fits your hypothesis is worthless unless it fits the alternatives worse.

A test that is right nine times in ten

David Eddy put the following to a group of physicians in 1978. Among women aged forty with no symptoms, about 1 percent have breast cancer. Mammography detects it in 79.2 percent of the women who have it, and returns a positive result for 9.6 percent of the women who do not. A woman in this group has a positive mammogram. What is the probability that she has cancer?

Ninety-five of the hundred physicians answered around 75 percent. The correct answer is

P(C|+)=0.01×0.7920.01×0.792+0.99×0.096=0.007920.00792+0.09504=0.007920.102960.0769

about 7.7 percent, off by a factor of ten. The test is not bad; the base rate is doing the damage. Only one woman in a hundred has the disease, so the 9.6 percent false positive rate is applied to ninety-nine times as many women as the 79.2 percent detection rate, and it wins on volume.

Nothing about this depends on medicine. Any test for a rare condition behaves this way, and the rarer the condition the worse it gets. Screen for something present in one person in ten thousand with a test that is 99 percent sensitive and gives 1 percent false positives, and a positive result leaves the probability at 0.0098, still under one percent. This is why mass screening for rare conditions is a hard policy problem rather than an obvious good, and why confirmatory tests exist.

Example. A drug test detects doping in 99 percent of dopers and returns a positive for 2 percent of clean athletes. Five percent of athletes in a sport dope. An athlete tests positive. What is the probability that they doped?

P(D|+)=0.05×0.990.05×0.99+0.95×0.02=0.04950.0495+0.019=0.04950.06850.7226

About 72 percent, high enough to investigate and nowhere near high enough to convict on its own.

Now you. In a different sport only 1 percent of athletes dope, with the same test. What is the probability that a positive athlete doped?

Answer
0.01×0.990.01×0.99+0.99×0.02=0.00990.0099+0.0198=0.00990.02970.3333

One third. The same test, the same accuracy, a base rate five times lower, and the conclusion flips from probable to unlikely.

Counting people instead of multiplying fractions

Gerd Gigerenzer showed in the 1990s that the same physicians who fail with percentages mostly succeed when the identical problem is posed in counts, and the reformulation is worth adopting permanently because it makes the answer visible without any formula.

Take 10000 women. About 100 of them have cancer, and of those, 79 test positive. The other 9900 do not have cancer, and 950 of them test positive anyway. So 79+950=1029 women test positive in total, of whom 79 have cancer:

7910290.077

the same answer, reached by dividing one count by another. The version with percentages hides the fact that the two groups being compared are of wildly different sizes; the version with counts puts the 9900 on the page where it cannot be forgotten. When you want to sanity-check any Bayes calculation, do it this way, with a round population and whole people.

Odds and the weight of evidence

There is a form of the theorem in which the awkward denominator disappears. Write Bayes for H and for Hc with the same evidence and divide one by the other. The P(E) cancels, leaving

P(H|E)P(Hc|E)=P(H)P(Hc)×P(E|H)P(E|Hc)

In words: posterior odds equal prior odds times the likelihood ratio. Odds of p against 1-p convert back to a probability by p=odds/(1+odds).

The likelihood ratio is the entire contribution of the evidence, and it is a property of the test alone, free of the base rate. For the mammogram it is 0.792/0.096=8.25: a positive result multiplies the odds by 8.25, whoever is tested and whatever they believed beforehand. That is the honest summary of what a test is worth, and it explains the earlier result at once. Prior odds of cancer are 1 to 99, or 0.0101. Multiply by 8.25 to get posterior odds of 0.0833, and convert: 0.0833/1.08330.0769. Multiplying odds by 8.25 sounds impressive and moves a probability of 0.01 only to 0.077, because odds far from one are hard to shift.

Repeated independent tests multiply their likelihood ratios, which makes sequential updating trivial. Two independent positive mammograms give odds 0.0101×8.252=0.6875, a probability of 0.4074. Three give odds 5.672 and a probability of 0.8501. Note also that the order of the evidence never appears in the product, so updating on E1 then E2 gives exactly what updating on E2 then E1 gives, and both equal updating on both at once. A Bayesian cannot be led anywhere by the sequencing of the evidence, only by its content.

Example. A blood test has likelihood ratio 12 for a positive result. A patient's prior probability of the condition is 0.05. What is the posterior probability after one positive?

Prior odds are 0.05/0.95=0.05263. Multiply by 12 to get 0.6316. Convert back: 0.6316/1.63160.3871, so about 39 percent.

Now you. The same patient tests positive a second time, independently. What is the probability now?

Answer

Multiply the odds by 12 again: 0.6316×12=7.579, giving 7.579/8.5790.8834, about 88 percent.

Negative results and the other error

A test has two ways of being wrong, and the odds form handles the second as easily as the first. The likelihood ratio for a negative result is P(-|H)/P(-|Hc), which for the mammogram is (1-0.792)/(1-0.096)=0.208/0.904=0.2301. A negative multiplies the odds by 0.23, cutting them by more than a factor of four.

Starting from prior odds of 1 to 99, a negative mammogram gives odds 0.0101×0.2301=0.002324, a probability of 0.002319, down from 0.01. So the test does useful work in both directions: it takes a one-in-a-hundred risk down to about one in four hundred and thirty. A likelihood ratio near 1, in either direction, is the signature of a test not worth doing, since it leaves the odds where it found them.

Example. For the drug test above, what is the likelihood ratio of a negative result, and what does a negative do to an athlete whose prior probability of doping was 0.05?

The ratio is (1-0.99)/(1-0.02)=0.01/0.98=0.010204. Prior odds 0.05/0.95=0.05263, so posterior odds are 0.000537 and the probability is 0.000537, roughly one in 1863.

Now you. A test has sensitivity 0.95 and false positive rate 0.10. What are its likelihood ratios for a positive and for a negative result?

Answer

Positive: 0.95/0.10=9.5. Negative: (1-0.95)/(1-0.10)=0.05/0.900.0556, which is a division of the odds by about 18.

What the theorem cannot give you

Bayes' theorem is a rule for revising a probability. It is not a rule for having one in the first place, and the prior has to come from somewhere outside it. In the mammography problem the prior was a measured population rate, which is uncontroversial. In a courtroom, or in assessing a scientific hypothesis, there is no population to count, and the prior is a judgement. Two honest people with different priors will reach different posteriors from the same evidence, and the theorem cannot arbitrate between them.

What it does guarantee is that they converge under enough evidence. Each new independent observation multiplies both people's odds by the same likelihood ratio, so a disagreement of a factor of a hundred in the prior is erased by evidence worth a factor of a hundred, and strong evidence swamps any prior that was not dogmatic. The exception is a prior of exactly 0 or 1, which multiplication can never move: certainty is not a strong opinion but an unreachable one, and this is the mathematical content of the advice to never be completely sure.

The theorem also silently assumes that the hypotheses listed are exhaustive. The denominator sums over the alternatives you thought of, so if the true explanation is not in the list, the posterior is confidently wrong. A high posterior means "best of what was considered", not "true".

So far every hypothesis and every event has been a yes-or-no affair. Most quantities of interest are not: how many defective items in a batch, how long until a component fails, how far a measurement is from its target. Attaching a number to each outcome, and asking what that number does on average, is the next step.

Random variables and expectation

Everything so far has been about events, which either happen or do not. Most questions worth asking concern a quantity instead: how many defective items, how long a wait, how much money. This lesson attaches numbers to outcomes, defines the average of such a number, and proves one property of that average that does more work than any other result in the subject.

A number attached to every outcome

A random variable is a function from the sample space to the real numbers. It assigns to each outcome ω a value X(ω). That is all it is, and the name is doubly misleading: it is not random, being a fixed function, and it is not a variable, being a function. The randomness lives in which outcome occurs, and X merely reports a number about it.

Roll two dice, so Ω is the 36 ordered pairs, and let X be the total. Then X((3,4))=7, and X is defined on every outcome with no ambiguity. Once X exists, statements about it become events in the old sense: "X=7" names the set of six pairs that total seven, and "X10" names a set of six pairs, so both have probabilities by the rules already established.

A variable taking values in a finite or countable set is discrete, which covers everything in this lesson and the next three. Its behaviour is captured completely by the probability mass function

p(x)=P(X=x)

which is non-negative and sums to 1 over all possible values, since the events {X=x} partition Ω. For the two-dice total, the mass function runs 1/36,2/36,,6/36,,2/36,1/36 across the values 2 to 12, and those eleven numbers sum to 36/36.

The mass function throws away the sample space, and that is its point. Two completely different experiments with the same mass function are interchangeable for every purpose that mentions only X. From here on the underlying Ω is rarely written down.

The average of a random variable

Suppose the experiment is repeated N times and X takes the value x on about Np(x) of them. The arithmetic mean of the observed values is then

1NxxNp(x)=xxp(x)

with N cancelling. That expression is taken as the definition of the expectation, also called the expected value or the mean:

E[X]=xxp(x)

It is a weighted average of the possible values, weighted by their probabilities, and it is a fixed number, not a random one. Whether the long-run average really converges to it is a theorem proved much later in this course, not an assumption made here.

For a single fair die, E[X]=(1+2+3+4+5+6)/6=3.5, a value the die can never show. Expectation is a centre of mass, not a prediction, and reading it as "what will happen" is the first of several ways it misleads. For the two-dice total, E[X]=7, which the sum can show, and which sits at the centre of the symmetric mass function.

Example. A European roulette wheel has 37 pockets: 18 red, 18 black and one green zero. You stake 1 unit on red, winning 1 if red comes up and losing your stake otherwise. What is the expected gain per spin?

E[X]=(+1)1837+(-1)1937=-137-0.02703

so the house keeps about 2.7 percent of everything staked, on average, whatever the bet.

Now you. An American wheel has 38 pockets, with both a zero and a double zero, so 18 are red. What is the expected gain per unit staked on red?

Answer

(+1)1838+(-1)2038=-238-0.05263, a house edge of 5.26 percent, almost exactly twice the European figure. One extra pocket doubles the cost of playing.

Functions of a random variable

If X is a random variable then so is g(X) for any function g, since a function of a function is a function. Its expectation could be found by first working out the mass function of g(X), and it never has to be, because

E[g(X)]=xg(x)p(x)

The proof is a regrouping: gather the outcomes according to the value of X rather than the value of g(X), and every outcome is still counted exactly once with its own probability. The result is often called the law of the unconscious statistician, from the habit of using it without noticing that it needs proof.

Two consequences are worth having on hand. First, E[aX+b]=aE[X]+b for constants a and b, since the sum splits and xp(x)=1. Expectation moves through a change of units unharmed: a temperature in Fahrenheit has 9/5 times the expected Celsius value plus 32. Second, E[X2] is generally not (E[X])2. For a fair die, E[X2]=(1+4+9+16+25+36)/6=91/615.1667, while (E[X])2=12.25. The gap of 2.9167 is not an error; the next lesson identifies it as the variance.

The practical consequence is that a payout must be averaged after the function is applied, never before. A stall charging 2 units to roll a die and paying out the square of the result takes in 2 and pays out E[X2]15.1667, losing about 13.17 units a play; pricing it from (E[X])2=12.25, or worse from E[X]=3.5, would have hidden that.

Linearity, which asks for nothing

Here is the result that earns its keep. For any random variables X and Y defined on the same sample space,

E[X+Y]=E[X]+E[Y]

The proof works outcome by outcome rather than value by value. Writing the expectation as a sum over Ω,

E[X+Y]=ω(X(ω)+Y(ω))P(ω)=ωX(ω)P(ω)+ωY(ω)P(ω)=E[X]+E[Y]

which is nothing but the associativity of addition. Notice what is absent: no independence, no assumption about how X and Y relate, not even that they are different quantities. It holds when Y=X, when Y=-X, when Y is a deliberately hostile function of X. Extended to any finite number of terms it says the expectation of a sum is always the sum of the expectations.

This is stronger than it looks, because most quantities of interest are sums of simple pieces whose joint behaviour is a nightmare and whose individual behaviour is trivial. The two-dice total illustrates the pattern in miniature: rather than summing xxp(x) over the eleven values with their awkward weights, write X=X1+X2 and get 3.5+3.5=7 immediately.

Example. Five cards are dealt from a shuffled deck. What is the expected number of hearts?

Let Xi be 1 if the card in position i is a heart and 0 otherwise, so the number of hearts is X1++X5. Each individual card is equally likely to be any of the 52, so E[Xi]=P(heart)=13/52=0.25. Linearity gives 5×0.25=1.25 hearts expected. The cards are emphatically not independent, since dealing a heart makes the next heart less likely, and linearity does not care.

Now you. Ten cards are dealt from the same deck. What is the expected number of aces?

Answer

Each position holds an ace with probability 4/52=1/13, so the expectation is 10/130.7692.

Indicators, and the problems they crack

The technique in that example deserves a name. An indicator variable IA takes the value 1 when the event A occurs and 0 when it does not, and its expectation is

E[IA]=1P(A)+0P(Ac)=P(A)

so expectation and probability are the same operation on indicators. Any count is a sum of indicators, one per thing that might be counted, and by linearity its expectation is the sum of the separate probabilities. Nothing about dependence ever enters.

Take the classic: n letters are put at random into n addressed envelopes. How many arrive at the right address? The exact distribution of the number of matches is a genuinely awkward object involving alternating sums. Its mean is not. Let Ii indicate that letter i is in its own envelope. Any given letter is equally likely to be in any of the n envelopes, so E[Ii]=1/n, and the expected number of matches is n×(1/n)=1 for every n. One letter arrives correctly on average, whether there are ten letters or ten million.

Or the coupon collector. There are n different coupons, one at random in each packet. Let Tk be the number of packets bought while holding exactly k distinct coupons. Each purchase in that stretch is new with probability (n-k)/n, and a wait for a success with constant probability p has expectation 1/p, proved in the lesson on the binomial family. So E[Tk]=n/(n-k), and the total is

E[T]=k=0n-1nn-k=n(1+12++1n)

For n=6, a full set of six needs 6×2.45=14.7 packets on average, and for n=50 it is 225. Collecting the last few is most of the work: the final coupon alone takes n packets on average.

Example. A fair die is rolled six times. What is the expected number of distinct faces seen?

Let If indicate that face f appears at least once. It fails to appear with probability (5/6)60.3349, so E[If]0.6651. Summing over the six faces gives 6×0.66513.99 distinct faces, about four.

Now you. A fair coin is tossed 10 times. What is the expected number of tosses that match the toss before them, out of the 9 adjacent pairs?

Answer

Each adjacent pair matches with probability 1/2, so the expectation is 9×0.5=4.5.

Where the mean is not enough

Expectation compresses a whole distribution into one number, and the compression discards things that matter.

Consider two propositions. The first pays 1 unit with certainty. The second pays 1000000 units with probability 10-6 and nothing otherwise. Both have expectation exactly 1, and nobody treats them as equivalent. Expectation cannot distinguish a certainty from a lottery, because it never asks how far the outcomes stray from their average.

The extreme case was posed by Nicolas Bernoulli in 1713. A coin is tossed until it lands heads; if this takes n tosses, the payout is 2n units. The probability of stopping at toss n is 2-n, so each term of the expectation contributes 2-n×2n=1, and the sum over infinitely many terms diverges. The expected payout is infinite, and no one will pay even 100 units to play, since a payout above 100 requires at least seven tosses, which happens with probability 2-6=0.015625, about once in 64 plays. Daniel Bernoulli's 1738 resolution, that people value money by something growing more slowly than the amount, launched utility theory, but the plain mathematical point stands on its own: an expectation can exist and be useless, or fail to exist while the variable is perfectly well behaved.

What is missing is a measure of how widely the values are spread around the mean. Building one, discovering that it adds when expectations of products do not, and extracting a guarantee about how far from the mean a variable can stray, is the next lesson.

Variance and spread

Expectation compresses a distribution to a single number and cannot tell a certainty from a lottery with the same average. This lesson builds the second number, the one that measures spread, and finds that it has a property expectation does not share and a consequence expectation cannot deliver.

Choosing a measure of spread

Spread means typical distance from the centre, so the obvious candidate is the mean of X-μ, writing μ=E[X] throughout. That candidate dies immediately: E[X-μ]=E[X]-μ=0 for every variable whatsoever, since the deviations above and below the mean cancel exactly. Any usable measure has to remove the signs first.

Two ways to do it. Take absolute values, giving the mean absolute deviation E|X-μ|, or take squares, giving E[(X-μ)2]. The absolute version is the more natural reading of "typical distance" and is almost never used, for reasons that are practical rather than deep. The absolute value has no derivative at zero and does not expand when a sum is substituted into it, so a formula containing it usually stays stuck. The square expands, and it is that expansion, three lines below, that produces the additivity the whole subject runs on.

So define the variance

operatorname{Var}(X)=E[(X-μ)2]

and, because squaring changed the units, the standard deviation σ=operatorname{Var(X)}, which is back in the units of X and is the number to quote. A variance is never negative, since it averages squares, and it is zero exactly when X equals μ with probability one.

Expanding the square gives a version that is easier to compute:

operatorname{Var}(X)=E[X2-2μX+μ2]=E[X2]-2μE[X]+μ2=E[X2]-μ2

so the variance is the mean of the square minus the square of the mean, and the gap noticed in the previous lesson between E[X2]=91/6 and (E[X])2=12.25 for a fair die is exactly its variance: 35/122.9167, with σ1.7078.

What scaling does

Shifting a variable moves its mean and leaves its spread alone; stretching it stretches the spread. Both facts follow from the definition. For constants a and b, the variable aX+b has mean aμ+b, so its deviation from its own mean is a(X-μ), and squaring introduces a2:

operatorname{Var}(aX+b)=a2operatorname{Var}(X),σaX+b=|a|σX

The additive constant vanishes entirely, which is right: adding ten to every value moves the whole distribution without spreading it. The factor a2 rather than a is the price of working with squares, and the standard deviation, taking the square root, scales the sensible way.

This licenses standardisation. Given any X with mean μ and standard deviation σ>0, the variable

Z=X-μσ

has mean 0 and variance 1, since the shift kills the mean and the division by σ divides the variance by σ2. A value of Z counts how many standard deviations X is from its mean, and it is dimensionless, so heights and test scores and share prices become comparable. This construction returns in the lesson on the normal curve, where it does most of the work.

A quick check on the rule: a game paying 10X+5 units on a roll of a fair die has mean 10(3.5)+5=40 units and standard deviation 10×1.7078=17.078 units, the additive 5 contributing nothing to the spread and everything to the centre.

Why variances add

Expectation adds unconditionally. Variance does not, and the exact condition is worth deriving. Let X and Y have means μX and μY. Then

operatorname{Var}(X+Y)=E[((X-μX)+(Y-μY))2]=operatorname{Var}(X)+operatorname{Var}(Y)+2E[(X-μX)(Y-μY)]

by expanding the square inside the expectation and using linearity on the three resulting terms. The last piece is the covariance

operatorname{Cov}(X,Y)=E[(X-μX)(Y-μY)]=E[XY]-E[X]E[Y]

which is positive when the two tend to be above their means together, negative when one being high goes with the other being low, and zero when there is no such tendency on average.

If X and Y are independent then E[XY]=E[X]E[Y], because the joint mass function factorises and the double sum splits into a product of two sums. So independence forces the covariance to zero and leaves

operatorname{Var}(X+Y)=operatorname{Var}(X)+operatorname{Var}(Y)

Two cautions. First, the implication runs one way only: zero covariance does not imply independence. Let X be -1, 0 or 1 with probability 1/3 each and Y=X2. Then E[XY]=E[X3]=0=E[X]E[Y], so the covariance vanishes, yet Y is a function of X and could hardly be more dependent. Covariance detects linear association and is blind to the rest.

Second, dependence can cancel spread entirely. Let Y=7-X for a die roll X. Both have variance 35/12, and their sum is the constant 7, whose variance is zero. Here the covariance is -35/12 and exactly cancels the two positive terms. Assuming variances add when the variables are linked is how a portfolio of correlated assets comes to look far safer than it is.

Example. Two fair dice are rolled independently. What are the variance and standard deviation of the total?

Each die has variance 35/12, and independence lets them add: operatorname{Var}=70/125.8333, so σ2.4152. The mean is 7, so a total is typically about two and a half away from seven.

Now you. Three independent fair dice are rolled. Find the variance and standard deviation of the total.

Answer

operatorname{Var}=3×35/12=105/12=8.75, so σ=8.752.9580, with mean 10.5.

The square root of n

Now take n independent copies of the same variable, each with mean μ and variance σ2: repeated measurements, repeated bets, repeated trials. Their sum Sn has mean nμ by linearity and variance nσ2 by additivity, so

σSn=σn

The sum's spread grows, but only as the square root of the number of terms, while its mean grows as n itself. Divide through to get the average Xn=Sn/n, which by the scaling rule has variance nσ2/n2=σ2/n and therefore

σXn=σn

This single formula is why measurements are repeated. Averaging four readings halves the spread, twenty-five readings divides it by five, ten thousand readings by a hundred. It is also a warning about cost: each further factor of two in precision costs four times the data, so precision gets expensive fast.

It also explains the two columns of Kerrich's coin table from the first lesson. The number of heads in n tosses has standard deviation n/2, which grows without bound, so the absolute surplus of heads drifts further from zero. The fraction of heads has standard deviation 1/(2n), which shrinks to nothing. Both columns behave exactly as they must, and neither is evidence about the coin.

Example. A measurement has standard deviation 0.8 grams. How many independent repeats are needed for the average to have a standard deviation of 0.1 grams?

Set 0.8/n=0.1, so n=8 and n=64 measurements. Halving that target again, to 0.05 grams, would take 256.

Now you. An opinion poll of 1000 people estimates a proportion whose standard deviation is at most 0.5/n. What is that bound for n=1000, and how many people would be needed to halve it?

Answer

0.5/10000.0158, about 1.6 percentage points. Halving it needs four times the sample: 4000 people.

Chebyshev's guarantee

Variance is more than a descriptive number: it bounds how much probability can sit far from the mean, for any distribution at all. Take any k>0 and let A be the event |X-μ|kσ. Then

σ2=E[(X-μ)2]E[(X-μ)2IA]k2σ2P(A)

The first inequality drops the contribution from outcomes outside A, which is non-negative. The second replaces (X-μ)2 by its minimum value on A, which is k2σ2 by the definition of A. Dividing by k2σ2 gives Chebyshev's inequality, published by Pafnuty Chebyshev in 1867:

P(|X-μ|kσ)1k2

No distribution can put more than a quarter of its probability two or more standard deviations from its mean, and never more than a ninth beyond three, whatever shape it has: no symmetry assumed, no bell curve, nothing but a finite variance.

The bound is very loose in practice, and deliberately so, since it must cover the worst case. Toss a fair coin 100 times: the number of heads has mean 50 and standard deviation 5, so Chebyshev caps P(|X-50|15) at 1/90.1111. The true value, computable exactly from the binomial formula of the next lesson, is 0.00352, smaller by a factor of thirty. Chebyshev is not for computing probabilities. It is for proving that they must be small, which is exactly what is needed to prove the law of large numbers later in this course.

Example. A production line fills bags with mean 500 grams and standard deviation 8 grams. What does Chebyshev guarantee about the fraction of bags between 480 and 520 grams?

The interval is μ±20 grams, which is k=20/8=2.5 standard deviations. Chebyshev bounds the outside at 1/2.52=0.16, so at least 84 percent of bags lie inside. If the weights happen to follow a normal curve the real figure is above 98 percent, and the guarantee holds whether or not they do.

Now you. For the same line, what fraction of bags does Chebyshev guarantee lie between 476 and 524 grams?

Answer

k=24/8=3, so at most 1/90.1111 lies outside and at least 88.9 percent lies inside.

What two numbers still miss

Mean and variance now exist for any variable with a finite second moment, they behave predictably under scaling, they add under independence, and they yield a universal tail bound. That is enough to say something about every distribution and not enough to say much about any particular one.

Two distributions can share a mean and a variance and look nothing alike. Symmetric and skewed, single-peaked and twin-peaked, bounded and unbounded: none of that is visible in the first two moments. Worse, some distributions have no finite variance at all, and for those Chebyshev says nothing and the square root of n law fails outright. Such heavy-tailed cases are not exotic curiosities; they appear in insurance losses and in financial returns, where a model chosen for its convenient variance quietly understates the risk of the events that matter.

The productive move is to stop treating distributions one at a time. A handful of mechanisms generate most of the distributions that occur, and each mechanism fixes the whole mass function, with the mean and variance falling out of it. The first and most important of those mechanisms is repeated independent trials with a fixed success probability, and it is the next lesson.

The binomial distribution

A distribution earns a name when one mechanism produces it over and over, and the commonest mechanism of all is a fixed number of independent attempts at the same thing. This lesson derives what that produces, tests it against a dice experiment run in 1894, and finds the regime where the formula stops being usable.

One trial, two outcomes

Start with the smallest case. A Bernoulli trial is an experiment with two outcomes, labelled success and failure, with P(success)=p. Its indicator X takes the value 1 or 0, and everything about it follows from the previous two lessons:

E[X]=1p+0(1-p)=p,E[X2]=1p+0(1-p)=p

so operatorname{Var}(X)=p-p2=p(1-p). That variance is worth a moment. It is zero at p=0 and at p=1, where the outcome is certain and there is nothing to vary, and it is largest at p=0.5, where it equals 0.25. Maximum uncertainty sits at even odds, which matches intuition and is here a consequence rather than an assertion. Writing q=1-p for the failure probability, the variance is pq.

The name is Jacob Bernoulli's, from Ars Conjectandi, written before his death in 1705 and published in 1713, which is also where the first law of large numbers appears.

Counting successes

Now run n such trials, independently, with the same p each time, and let X be the number of successes. Any particular sequence with k successes and n-k failures has probability pkqn-k by independence, and this does not depend on the order in which the successes fell. So the probability of k successes is that quantity times the number of sequences that have k successes, which is the number of ways to choose which trials succeeded:

P(X=k)=C(n,k)pkqn-k,k=0,1,,n

This is the binomial distribution, written XBin(n,p), and both ingredients came from earlier lessons: the counting of positions from the combinations lesson, the multiplication of probabilities from independence. The masses sum to 1 because the right-hand side is the general term of the binomial theorem applied to (p+q)n=1n=1, which is where the name comes from.

Toss a fair coin ten times. The probability of exactly three heads is C(10,3)(0.5)10=120/10240.1172, and the probability of eight or more is (45+10+1)/1024=56/10240.0547. That last figure is worth remembering: getting eight or more heads out of ten is not rare enough to prove anything about a coin.

Three conditions are being assumed, and each fails somewhere real. The number of trials is fixed in advance, so stopping when you like invalidates the formula. The trials are independent, which fails for cards dealt without replacement. And p is the same throughout, which fails when a machine drifts as it heats up.

Example. A machine produces items with a 5 percent defect rate, independently. In a box of 20, what is the probability of no defects, and of two or more?

P(0)=0.95200.3585. P(1)=20(0.05)(0.95)190.3774. So P(2)=1-0.3585-0.37740.2642. More than a quarter of boxes carry at least two defects, even though the expected number is only 1.

Now you. For the same machine, what is the probability that a box of 10 contains no defects?

Answer

0.95100.5987, so just under 60 percent of small boxes are clean.

Mean and variance without a single sum

The direct route to E[X] is kkC(n,k)pkqn-k, which can be done and is unpleasant. The indicator route is two lines.

Write X=I1+I2++In, where Ij indicates success on trial j. Linearity of expectation, which needs nothing at all, gives

E[X]=np

Independence lets the variances add too, and each contributes pq:

operatorname{Var}(X)=npq,σ=npq

Ten fair tosses have mean 5 and standard deviation 10×0.251.58. The box of twenty items has mean 1 and standard deviation 20(0.05)(0.95)0.9747.

The shape follows from the ratio of consecutive masses,

P(X=k)P(X=k-1)=(n-k+1)pkq

which decreases as k grows, so the masses rise while that ratio exceeds 1 and fall afterwards. The distribution therefore has a single peak, located at k=(n+1)p, close to the mean np as it should be. At p=0.5 the mass function is symmetric, since swapping successes for failures leaves it unchanged, and away from 0.5 it is skewed towards the boundary it is furthest from.

Weldon's twenty-six thousand throws

In 1894 Raphael Weldon threw twelve dice together, over and over, and recorded how many showed a five or a six. He did this 26306 times, which is 315672 individual dice rolls, and sent the tally to Karl Pearson. On fair dice the probability of a five or six is 1/3, so each throw of twelve should give Bin(12,1/3), with mean 4 successes.

The observed total was 106602 successes, an average of 4.0524 per throw, giving pˆ=106602/3156720.33771 against the theoretical 0.33333. The excess looks tiny. Ask whether it could be chance, using the machinery just built: if p were exactly 1/3, the total number of successes would have mean 315672/3=105224 and standard deviation 315672×13×23}264.9. The observed total is 1378 above the mean, which is 5.2 standard deviations out. Chebyshev alone caps that at 1/5.220.037, and the true figure is vastly smaller.

So the dice were not fair, and the reason is manufacturing: the pips are drilled into the faces, removing material, so the six face is lightest and lands uppermost slightly more often than a third of the time. This is what a probability model earns its keep by doing. A model precise enough to be wrong turned a 0.4 percentage point discrepancy, invisible to any player, into a definite statement about how dice are made.

Example. A drug is claimed to be no better than a coin toss at curing a condition. In a trial of 8 patients it cures 7. Under the coin-toss hypothesis, how likely is a result this extreme or more?

P(X7)=(C(8,7)+C(8,8))/28=(8+1)/2560.0352. About one trial in twenty-eight would do this well by luck alone, which is suggestive and thin, and it is why trials are not run on eight patients.

Now you. In a trial of 10 patients the drug cures 9. Under the same hypothesis, how likely is nine or more?

Answer

(C(10,9)+C(10,10))/210=11/10240.0107, about one in ninety-three.

Waiting instead of counting

The binomial fixes the number of trials and lets the number of successes vary. Turn it around: fix the goal at one success and let the number of trials vary. Let Y be the trial on which the first success occurs. The first k-1 trials must fail and the kth must succeed, so

P(Y=k)=qk-1p,k=1,2,3,

the geometric distribution. Its masses form a geometric series with first term p and ratio q, summing to p/(1-q)=1, so it is a legitimate distribution on an infinite sample space, the one promised in the second lesson.

Its mean can be found by a trick that avoids summing kqk-1p. Condition on the first trial. With probability p it succeeds and Y=1. With probability q it fails, and the situation afterwards is identical to the start, so the remaining wait has the same expectation E[Y]. Hence

E[Y]=p(1)+q(1+E[Y])=1+qE[Y]E[Y]=1p

Waiting for a six on a fair die takes 6 rolls on average; waiting for a lottery win at one in 13983816 takes that many draws. The same self-similarity argument gives the variance, q/p2.

That self-similarity is the geometric distribution's defining property, and it is called memorylessness: given that the first m trials failed, the remaining wait has exactly the original distribution. A machine that has run for a thousand hours without failing is, under this model, as good as new. That is sometimes true, for failures caused by external shocks, and often false, for anything that wears out. Noticing which case applies is a modelling decision the mathematics cannot make.

Example. A basketball player scores each free throw with probability 0.8, independently. What is the probability that their first miss is on the fourth attempt, and how many attempts until the first miss on average?

A miss is the "success" here, with p=0.2. So P(Y=4)=0.83×0.2=0.1024, and E[Y]=1/0.2=5 attempts.

Now you. A fair die is rolled until a six appears. What is the probability that this takes exactly three rolls?

Answer

(5/6)2(1/6)=25/2160.1157.

Where the formula gives out

The binomial is exact, and it becomes unusable in a regime that occurs constantly.

Consider a factory making 10000 components a day, each defective with probability 0.0003, or a city of a hundred thousand people each having a rare accident on a given day, or a stretch of DNA with a per-base mutation chance in the millionths. These are binomials with n enormous and p minuscule. The formula demands C(10000,k), which for moderate k is a number with hundreds of digits, multiplied by pk, which is vanishingly small, and the two nearly cancel. Computed directly in ordinary arithmetic this overflows and then underflows, and even done carefully it obscures what is going on.

Look at what stays fixed as the regime is entered. The mean np is a sensible number, three defective components a day, and the variance npq is nearly the same, since q1. Both depend on n and p only through their product, which suggests the distribution itself might too, in the limit where n grows and p shrinks with np held constant.

It does, and the limiting law has a one-line formula, a single parameter, and a striking record against real count data. It is the next lesson.

Rare events and the Poisson law

The binomial formula becomes unusable when the number of trials runs into the thousands and the success probability into the thousandths, which is exactly the regime of accidents, faults, arrivals and decays. This lesson takes the limit, finds a one-parameter law with a one-line formula, and checks it against three sets of real counts, one of which decided a wartime question about whether bombs were being aimed.

Taking the limit

Start from the binomial with n trials and success probability p, and hold the mean fixed at λ=np while letting n grow, so p=λ/n shrinks. Write out the mass function and group the pieces:

P(X=k)=n(n-1)(n-k+1)k!(λn)k(1-λn)n-k
=λkk!n(n-1)(n-k+1)nk(1-λn)n(1-λn)-k

Each of the three trailing factors has an easy limit with k and λ held fixed. The first is a product of k ratios each tending to 1, since (n-j)/n1. The second is the definition of the exponential met in the foundations course, (1+x/n)nex, giving e-λ. The third tends to 1 because λ/n tends to 0 and k is fixed. What survives is the Poisson distribution:

P(X=k)=e-λλkk!,k=0,1,2,

named for Siméon Denis Poisson, who published it in 1837 in a book about the reliability of jury verdicts, where it went largely unnoticed for sixty years.

It is a legitimate distribution because kλk/k! is the series for eλ, so the masses sum to e-λeλ=1. There is one parameter, no n and no p separately, only their product. That is the practical payoff: to use it you need the average rate and nothing else, and the average rate is usually the one thing that has been measured.

The convergence is fast. With n=1000 and p=0.003, so λ=3, the binomial gives P(X=0)=0.049563 against the Poisson 0.049787, and P(X=3)=0.224379 against 0.224042. Agreement to three decimal places, with the exact calculation requiring C(1000,3) and the approximation requiring a pocket calculator.

Mean, variance, and a test you can run

Both moments follow from the limit. The binomial mean np is λ by construction, and the binomial variance np(1-p) tends to λ as well, since p0. So

E[X]=λ,operatorname{Var}(X)=λ

Mean equals variance, which is unusual and useful. It gives a free diagnostic: compute the sample mean and the sample variance of any set of counts, and if they differ substantially the Poisson model is wrong. Counts more spread out than their mean, called overdispersed, indicate clustering, meaning the events are not independent. Counts less spread out indicate some regulating mechanism spacing them apart.

Example. A call centre receives on average 4 calls a minute. What is the probability of exactly 2 calls in a given minute, and of none at all?

P(2)=e-442/2!=e-4×80.1465. P(0)=e-40.0183, so a completely quiet minute happens about once every fifty-five minutes.

Now you. A shop averages 2.5 customers per five-minute period. What is the probability that a given five-minute period has none?

Answer

P(0)=e-2.50.0821, about one period in twelve.

Horse kicks

Ladislaus von Bortkiewicz published the first serious test of this law in 1898, in a book whose title translates as The Law of Small Numbers. He took Prussian army records of soldiers killed by horse kicks, for ten cavalry corps over the twenty years from 1875 to 1894: 200 corps-years, and 122 deaths in total.

Each corps-year is a huge number of opportunities, since many soldiers stand near many horses on many days, each with a tiny chance of a fatal kick. That is the Poisson regime, with λ=122/200=0.61 deaths per corps-year. The prediction for the number of corps-years with k deaths is 200e-0.61(0.61)k/k!:

Deaths in a corps-yearObservedPoisson prediction
0109108.7
16566.3
22220.2
334.1
410.6

The fit is close enough to be slightly eerie, and it was obtained from a single number, the average. Nothing about horses, soldiers or Prussia entered the calculation. Whenever a great many independent opportunities each carry a tiny probability, the counts fall into this shape regardless of what the opportunities are.

Bombs on London

In 1946 R. D. Clarke, an actuary, published a two-page paper applying the same test to a question that had mattered a great deal in 1944. During the V-1 flying bomb attacks, south London appeared to be hit in clusters, and the natural inference was that the weapons were being aimed accurately enough to concentrate on particular districts, which had consequences for whether people should be moved.

Clarke divided a 144 square kilometre area of south London into 576 squares of a quarter of a square kilometre each, and counted the 537 hits that fell in it. If the bombs landed at random, the count per square is Poisson with λ=537/576=0.9323.

Hits in a squareObservedPoisson prediction
0229226.7
1211211.4
29398.5
33530.6
477.1
5 or more11.6

The agreement is excellent, so the bombs were falling at random and the apparent clusters were what randomness looks like. This is the point worth carrying away. Random scatter is lumpy. A uniform sprinkling with no gaps and no clumps would be evidence of aiming, not of chance, and the human eye reads clumps as design. Under this model 93+35+7+1=136 of the 576 squares should take two or more hits, and 136 did.

Example. Using Clarke's λ=0.9323, what fraction of squares would be expected to take no hits at all, and how many of the 576 is that?

P(0)=e-0.93230.3937, so 576×0.3937226.7 squares, against 229 observed. Nearly two in five squares escape entirely, which is what makes the hit squares look concentrated.

Now you. A different area is divided into 400 squares taking 600 hits in total. How many squares would be expected to take no hits?

Answer

λ=600/400=1.5, so P(0)=e-1.50.2231 and the expected count is 400×0.223189.3 squares.

Counting in time

The two examples above counted events in space and in years, and the general structure has a name. A Poisson process of rate λ per unit of time is a stream of events with three properties: the number in any interval depends only on its length, counts in disjoint intervals are independent, and events do not coincide. Chop an interval of length t into n tiny slices, each holding an event with probability about λt/n, and the limit above gives a Poisson count with parameter λt.

Rutherford, Geiger and Bateman tested this in 1910 on radioactive decay, counting alpha particles from a polonium source in 2608 intervals of 7.5 seconds each. They recorded 10097 particles, a mean of 3.87 per interval, against which the Poisson prediction runs 54.3, 210.3, 407.1, 525.3, 508.4 for zero through four particles, against observed counts of 57, 203, 383, 525, 532. Radioactive decay is the cleanest Poisson process known, because nuclei genuinely do not influence one another and genuinely do not age.

Example. A web server receives requests as a Poisson process at 3 per second. What is the probability of at least 3 requests in a given second?

P(0)+P(1)+P(2)=e-3(1+3+4.5)=e-3×8.50.4232, so P(3)0.5768.

Now you. For the same server, what is the probability of at least 2 requests in a half second interval? Note that halving the interval halves the parameter.

Answer

Here λ=1.5, so P(0)+P(1)=e-1.5(1+1.5)0.5578 and P(2)0.4422.

Where the model breaks

The Poisson law assumes independence and a constant rate, and real count data violates both routinely.

Traffic accidents at a junction cluster, because one crash causes the next. Insurance claims from storms cluster, because one storm causes many. Goals in football arrive at a rate that changes with the score. In each case the counts are overdispersed, with variance well above the mean, and using a Poisson model understates the chance of a very bad period, which is precisely the number an insurer or a hospital needs. The mean-equals-variance check catches this in one calculation, which is why it is worth doing before anything else.

There is also a limit of a different kind, and it applies to everything in the course so far. Every distribution met up to here is discrete: the variable takes values in a list, and probability is assigned to individual values. Ask for the exact time until the next alpha particle rather than the count in an interval, or the exact position of a bomb rather than which square it fell in, and the list becomes a continuum. Assigning a positive probability to each of uncountably many values is impossible, since they would sum to more than one, and yet one of those values does occur.

Resolving that, by replacing the sum with an area and the mass function with a density, is the next lesson.

Continuous random variables

Every distribution so far has assigned probability to individual values in a list. A measurement does not come in a list: a waiting time, a length, a temperature can take any value in an interval, and there are uncountably many of them. This lesson works out what probability has to look like on a continuum, and derives two laws that are already implicit in earlier lessons.

Why no single value can have probability

Suppose a needle is spun and lands at an angle anywhere in [0,360) degrees, with no direction favoured. What is the probability that it lands at exactly 90 degrees?

Whatever answer c you give must be the same for every angle, by symmetry. If c>0, then any n distinct angles form a disjoint collection with total probability nc, and choosing n larger than 1/c makes that exceed one, contradicting the axioms. So c=0. Every individual angle has probability zero, and yet the needle lands somewhere, so an outcome with probability zero has just occurred.

This is not a paradox, only a consequence of countable additivity not extending to uncountable collections. The complement rule survives intact: an event of probability zero is not impossible, and an event of probability one is not certain. The second lesson flagged this and here is where it bites.

If single values carry nothing, then probability has to be carried by intervals. For the needle, symmetry says the probability of landing in an interval is proportional to its length, and [0,360) has probability one, so an interval of width w degrees has probability w/360. Probability has become a measure of size, which is what makes the continuous theory work.

Density and area

Write the interval probability as a rate times a width. For the needle the rate is 1/360 per degree, constant across the range. In general the rate varies, and the function giving it is the probability density function f(x), defined so that

P(aXb)=the area under f between a and b

which in the notation of calculus is abf(x)dx. The density is not a probability, and it may exceed one: a variable confined to [0,0.1] and spread evenly has density 10 per unit, and the total area is still 0.1×10=1. What a density has are units, namely probability per unit of x. Reading f(x) as "the probability of x" is the standard beginner's error, and the units are what expose it.

Two requirements make a function a density: it is never negative, and the total area under it is exactly 1. Those are the continuous forms of the two conditions on a mass function.

The simplest case is the uniform distribution on [a,b], with f(x)=1/(b-a) across that interval and zero outside. Its areas are rectangles, so every probability is a ratio of lengths: for a variable uniform on [2,8], P(3X5)=2/60.3333, and P(X>6)=2/6 as well. Since single points contribute no area, it makes no difference whether the endpoints are included, and P(X<5) and P(X5) are the same number. That convenience is unique to the continuous case.

The function that works for both

Densities do not exist for discrete variables and masses do not exist for continuous ones, but one object exists for every random variable whatsoever. The cumulative distribution function is

F(x)=P(Xx)

It runs from 0 far to the left to 1 far to the right, never decreases, and gives interval probabilities by subtraction: P(a<Xb)=F(b)-F(a). For a discrete variable it is a staircase, jumping at each value by that value's mass. For a continuous one it is a continuous climb, and the density is its rate of change, so density and cumulative function carry the same information in two forms.

The cumulative function is the object to reach for when a distribution has to be handled numerically, since published tables and software routines nearly always give F rather than f. It is also the natural home of quantiles: the value xq with F(xq)=q splits the distribution so that a fraction q lies below. The median is the case q=0.5.

Example. A bus arrives at a time uniform on the interval from 0 to 10 minutes after you reach the stop. Write down the cumulative function and use it to find the probability of waiting between 3 and 7 minutes.

The density is 1/10 per minute, so F(x)=x/10 for x in [0,10], zero below and one above. Then P(3<X7)=F(7)-F(3)=0.7-0.3=0.4.

Now you. For the same bus, find the probability of waiting more than 8 minutes, and find the median wait.

Answer

P(X>8)=1-F(8)=1-0.8=0.2. The median solves x/10=0.5, giving 5 minutes.

Mean and spread by area

Expectation was a sum of value times mass. On a continuum it becomes a sum of value times density times width, which is an area calculation:

E[X]=xf(x)dx,operatorname{Var}(X)=(x-μ)2f(x)dx=E[X2]-μ2

Everything proved about expectation and variance in the earlier lessons carries over unchanged, because the proofs used only linearity and the fact that probabilities sum to one, both of which survive the replacement of sums by areas. Linearity still holds with no independence, variances still add for independent variables, Chebyshev's inequality still applies, and standardising still gives mean 0 and variance 1.

For the uniform distribution on [a,b] the mean is (a+b)/2 by symmetry, and the variance works out to

operatorname{Var}(X)=(b-a)212

The 12 is not guessable and the shape of the answer is: the variance depends only on the width, since shifting the interval cannot change the spread, and it scales as the square of the width, as the scaling rule requires. A uniform on [0,1] therefore has variance 1/120.0833 and standard deviation 0.2887, which is well under the half-width of 0.5, as it must be, since the standard deviation is an average distance and 0.5 is the maximum.

Example. A variable is uniform on [2,8]. Find its mean, variance and standard deviation.

Mean (2+8)/2=5. Variance (8-2)2/12=36/12=3. Standard deviation 31.7321.

Now you. A variable is uniform on [0,10]. Find its mean and standard deviation.

Answer

Mean 5, variance 100/128.3333, standard deviation 2.8868.

Waiting for a Poisson event

The second continuous law needs no new ideas at all, only the previous lesson read differently.

Take a Poisson process of rate λ per unit time, and let T be the time until the first event. Then T>t says exactly that the interval [0,t] contained no events, and the count in that interval is Poisson with parameter λt, so

P(T>t)=e-λtF(t)=1-e-λt

for t0. This is the exponential distribution, and its density is f(t)=λe-λt, decreasing from λ at zero. Its mean is 1/λ, which is the only answer dimensional sense allows: a rate of 3 events per second must give an average wait of a third of a second. Its standard deviation is also 1/λ, so the wait is as spread out as it is long, and its median is ln2/λ0.6931/λ, noticeably shorter than the mean because the distribution is skewed to the right.

The exponential is the continuous twin of the geometric, and it inherits memorylessness in the same form:

P(T>s+t|T>s)=e-λ(s+t)e-λs=e-λt=P(T>t)

Having waited s already tells you nothing. A radioactive nucleus that has survived a million years is exactly as likely to decay in the next hour as a freshly made one, and this is why radioactive decay is described by a half-life at all: the half-life is the median, ln2/λ, and it is the same whatever the age of the sample. Carbon-14 has a half-life of 5730 years, so its decay rate is λ=ln2/5730 per year and the mean lifetime of an individual atom is 1/λ=5730/ln28267 years. Mean and median differ by a factor of 1.44, and quoting the wrong one is a real source of error.

Memorylessness is also the exponential's biggest limitation. Anything that wears out, corrodes or fatigues has a failure rate that climbs with age, and modelling it as exponential systematically underestimates late-life failure. The test is easy to state: if the conditional chance of failing in the next hour depends on how long the item has already run, the exponential is the wrong model.

Example. A light bulb's lifetime is exponential with a mean of 1000 hours. What is the probability that it lasts more than 1500 hours, and what is the probability it fails within the first 500?

With λ=1/1000, P(T>1500)=e-1.50.2231 and P(T<500)=1-e-0.50.3935. Nearly 40 percent of bulbs fail in the first half of their mean lifetime, which is the skew showing.

Now you. Buses arrive as a Poisson process at 0.5 per hour. What is the probability of waiting more than 3 hours for the next one?

Answer

λt=0.5×3=1.5, so P(T>3)=e-1.50.2231.

Every mechanism, its own shape

The catalogue is now four laws deep. Independent trials counted give the binomial; the same trials waited for give the geometric; the rare-event limit gives the Poisson; the wait for a Poisson event gives the exponential. Each came from a mechanism, and each has a shape of its own: the binomial peaked and bounded, the geometric and exponential decaying from the left edge, the Poisson skewed at small λ and less so at large.

Nothing suggests that any one shape should be more fundamental than another, and one of them is. Measured heights, weights, errors of observation and test scores fall repeatedly into a single symmetric curve that appears in none of the mechanisms above. More strangely, so do sums of things drawn from the laws above: add enough exponentials, or enough dice, or enough Bernoulli trials, and the resulting distribution converges on that same curve regardless of what went in.

The curve, and the calculations it makes routine, is the next lesson. The reason it is unavoidable is the lesson after that.

The normal curve

Four distributions in this course came from four different mechanisms and have four different shapes. A fifth shape appears in measurement after measurement without any obvious mechanism behind it at all, and this lesson takes it as given, learns to compute with it, and is honest about where it does not belong. Why it is unavoidable is the next lesson.

The curve and its two parameters

The normal or Gaussian density is

f(x)=1σ2πe-(x-μ)2/(2σ2)

and although it looks arbitrary, each piece has a job. The exponent is a negative multiple of the squared distance from μ, so the curve is symmetric about μ and falls away in both directions. It falls extremely fast, because the exponent grows with the square of the distance, and this is what makes the tails so thin. The σ2 in the denominator of the exponent sets the horizontal scale, so the curve is wide when σ is large. The factor in front is fixed by the requirement that the total area equal 1, and the 2π is the constant that makes it so, a result from calculus that this course takes on trust.

The parameters are exactly the mean and the standard deviation, both of which follow from the symmetry and from an integral. So a normal distribution is completely determined by its first two moments, which is a strong and unusual property: for a binomial you also need n and p separately, and for most families two numbers do not fix the shape.

Abraham de Moivre found the curve in 1733 as an approximation to the binomial for large n, in a private pamphlet, and it lay unused. Carl Friedrich Gauss arrived at it again in 1809 from a completely different direction, asking what error distribution would make the arithmetic mean the best estimate of a measured quantity, and found this one. Two unrelated routes to the same curve was the first hint that something general was going on.

One curve, one table

The density has no elementary antiderivative, so areas under it cannot be written in closed form and must be looked up or computed numerically. Doing that separately for every μ and σ would be hopeless, and the scaling rule from the variance lesson removes the need. Standardise:

Z=X-μσ

which has mean 0 and variance 1, and which is still normal, because subtracting and dividing by constants only shifts and stretches the curve. So every normal question reduces to a question about the standard normal, whose cumulative function is written Φ(z). One table, or one library function, serves every case.

The recipe is mechanical. To find P(Xx), compute z=(x-μ)/σ and read Φ(z). To find a probability between two values, subtract. For the upper tail use 1-Φ(z), and use the symmetry Φ(-z)=1-Φ(z) to avoid needing negative arguments at all.

The figures everyone quotes come straight out of this. The area within one standard deviation of the mean is Φ(1)-Φ(-1)=2Φ(1)-1=0.682689. Within two it is 0.954500, within three 0.997300, and within four 0.999937. Rounded, that is the 68, 95, 99.7 rule, and it is worth noticing how brutal the decay is: the chance of landing beyond four standard deviations is about 1 in 15800, and beyond five about 1 in 1.7 million. Compare Chebyshev's guarantee from the earlier lesson, which allowed up to 1/9 beyond three standard deviations for an arbitrary distribution against the normal's 0.0027. Assuming normality buys enormous precision in the tails, and losing that assumption is expensive in exactly the same place.

Example. A population of adult men has mean height 175 cm with standard deviation 7 cm, close to the figures reported for England. What proportion are taller than 190 cm?

Standardise: z=(190-175)/7=2.1429. Then Φ(2.1429)=0.98394, so the upper tail is 1-0.98394=0.01606, about 1.6 percent, or one man in 62.

Now you. For the same population, what proportion are between 168 and 182 cm tall?

Answer

Those bounds are exactly one standard deviation either side of the mean, so the answer is 2Φ(1)-1=0.6827, about 68 percent.

Reading the table backwards

The recipe above answers "what fraction lies beyond this value". The reverse question, "what value has this fraction beyond it", is answered by running Φ backwards, and it is the form most decisions take.

Two values are worth memorising because they appear everywhere. Φ(1.645)=0.95, so five percent of a normal distribution lies above 1.645 standard deviations from the mean. And Φ(1.96)=0.975, so two and a half percent lies above 1.96 standard deviations and, by symmetry, ninety-five percent lies within ±1.96. That second figure is where the ubiquitous "1.96" in confidence intervals and polling margins comes from, and the next lesson derives that use of it in full.

Converting back to the original units is the scaling rule in reverse: the value with fraction q below it is xq=μ+zqσ. For the height population above, the ninety-fifth percentile is 175+1.645(7)=186.5 cm, and the fifth percentile is 175-1.645(7)=163.5 cm. A design that must fit ninety-five percent of the population is sized to the first of those, and the five percent it excludes are the price of the choice, stated rather than hidden.

Percentile talk is normal-curve talk in disguise wherever it is used on test scores, growth charts and reference ranges. The clinical convention of flagging results outside the central ninety-five percent of a reference population is exactly the ±1.96 rule, and it guarantees that one healthy person in twenty is flagged, which is the multiple comparisons problem of the last lesson waiting to happen.

Normal plus normal is normal

One property makes the normal indispensable in practice: independent normal variables add to a normal variable. If X is normal with mean μ1 and variance σ12, and Y is independent normal with μ2 and σ22, then X+Y is normal with mean μ1+μ2 and variance σ12+σ22.

The means and variances combining that way is nothing new, since linearity and independent additivity were proved for all variables. What is new is that the shape is preserved. Add two uniforms and you get a triangle, not a uniform. Add two exponentials and you get something with a peak away from zero. The normal is a fixed point of addition, and combined with the fact that it approximates so much else, that is why it propagates through any calculation that adds things up.

Example. A component's length is normal with mean 50.0 mm and standard deviation 0.3 mm. Four are stacked end to end, independently. What is the distribution of the total length, and what fraction of stacks exceed 201 mm?

The total is normal with mean 200.0 mm and variance 4(0.09)=0.36, so its standard deviation is 0.6 mm, not 1.2 mm. Then z=(201-200)/0.6=1.6667, so the fraction above is 1-Φ(1.6667)=0.0478, about 4.8 percent.

Now you. Nine such components are stacked. What are the mean and standard deviation of the total length?

Answer

Mean 450.0 mm. Variance 9(0.09)=0.81, so the standard deviation is 0.9 mm. Nine times the components, three times the spread.

Approximating the binomial

De Moivre's original purpose still works, and it is the practical way to handle a binomial with large n. A Bin(n,p) variable has mean np and variance np(1-p), and for large n its mass function is closely matched by the normal curve with those parameters.

One adjustment is needed. The binomial is discrete and the normal is continuous, so a bar of the mass function at k is represented by the strip of normal area from k-0.5 to k+0.5. Using those half-unit boundaries is the continuity correction, and skipping it is the usual source of a poor approximation.

Take 100 fair coin tosses and ask for P(X60). The mean is 50 and the standard deviation is 100×0.25=5. With the correction, the boundary is 59.5, so z=(59.5-50)/5=1.9 and the tail is 1-Φ(1.9)=0.028717. The exact binomial answer is 0.028444, so the error is under one percent of the value. Without the correction the boundary would be 60, giving z=2 and 0.02275, which is wrong by twenty percent. The correction is not a refinement, it is the difference between a usable answer and a bad one.

The approximation is good when np and n(1-p) both comfortably exceed about 10, which keeps the binomial from being squashed against either boundary. When p is tiny and np is small, the right approximation is the Poisson of the earlier lesson instead.

Example. A fair coin is tossed 100 times. Estimate the probability that the number of heads differs from 50 by at least 15, and compare with the exact value.

The boundaries with continuity correction are 50±14.5, so z=14.5/5=2.9 and the two-sided tail is 2(1-Φ(2.9))=0.003732. The exact binomial value is 0.003518. Chebyshev, for the same question, allowed anything up to 0.1111.

Now you. For the same 100 tosses, estimate P(X55) using the normal approximation with continuity correction.

Answer

The boundary is 54.5, so z=4.5/5=0.9 and the answer is 1-Φ(0.9)0.1841. The exact binomial value is 0.1841 as well, to four places.

Where the curve does not belong

The normal is a model, and it is applied far outside the range where it is warranted. Three failures are worth being able to spot.

The curve extends to infinity in both directions, so a normal model always assigns positive probability to negative values. For heights with mean 175 cm and standard deviation 7 cm, negative height is twenty-five standard deviations out and the probability is unimaginably small, so the defect is harmless. For a quantity whose mean is close to zero relative to its spread, such as a rainfall total or a waiting time, the defect is fatal, and the model will predict impossible outcomes at a noticeable rate.

Second, the tails are extraordinarily thin, and many real quantities have tails that are not. Daily returns on financial assets are the standard example: moves of more than five standard deviations should occur roughly once in 7000 years of trading days under a normal model, and they occur every few years. Insurance losses, city sizes, file sizes and word frequencies behave similarly. Fitting a normal to such data produces a model that is comfortable, tractable and wrong precisely about the events that matter, which is worse than having no model.

Third, quantities generated by multiplication rather than addition are not normal but log-normal: their logarithm is normal, and their own distribution is skewed right with a long tail. Incomes, particle sizes and biological growth often behave this way, since the next value is the previous one times a random factor. The tell is a distribution whose mean noticeably exceeds its median.

A good habit is to ask why the quantity should be normal before assuming it is. The honest answer is usually that it is a sum of many small independent contributions, and that answer is a theorem rather than a hope. Stating that theorem, and the companion result about why averages settle down at all, is the next lesson.

The laws of large numbers

The first lesson left a debt. It claimed that measured frequencies stabilise, could not justify it, and took the axioms as a starting point instead. Everything since then has been built on those axioms, and they now suffice to pay the debt back with interest: not only do averages settle, but the residual error has a shape that can be computed, and the shape does not depend on what was being averaged.

What has to be proved

Take independent repetitions X1,X2, of the same experiment, each with mean μ and finite variance σ2, and let

Xn=X1++Xnn

be the average of the first n. The claim to be proved is that Xn closes in on μ. Applied to indicators, where Xi is 1 when an event occurs and 0 otherwise, Xn is the observed frequency of that event and μ is its probability, so proving the general claim proves the specific one about coin tosses.

Two ingredients are already in hand. By linearity, E[Xn]=μ for every n, so the average is centred correctly from the very first trial. By the additivity of variance for independent variables and the scaling rule,

operatorname{Var}(Xn)=σ2n

so the spread of the average shrinks towards zero. Centred correctly and shrinking: that is nearly the whole proof, and Chebyshev supplies the rest.

The weak law

Chebyshev's inequality, applied to Xn with its mean μ and standard deviation σ/n, says that for any fixed tolerance ε>0,

P(|Xn-μ|ε)σ2nε2

obtained by setting kσ/n=ε in the inequality. The right-hand side is a constant divided by n, so it tends to zero. That is the weak law of large numbers: for every tolerance, however tight, the probability that the average misses the true mean by more than that tolerance can be driven as low as you like by taking enough trials.

The proof is three lines and it uses only results already established, which is worth pausing on. Bernoulli's original proof in Ars Conjectandi, published in 1713, ran to twenty pages and he worked on it for twenty years. Chebyshev's inequality of 1867 collapsed it, and the collapse is what a good abstraction buys.

Note what the theorem does not claim. It does not say Xn eventually stays near μ; for each n separately it bounds a probability, and a rare excursion at some later n is not excluded. Strengthening it to "with probability one, the sequence of averages converges to μ and stays there" is the strong law of large numbers, proved for coin tossing by Émile Borel in 1909 and in general by Kolmogorov in 1930. The strong law needs no variance at all, only a finite mean. Its proof is genuinely harder and is not attempted here; the statement is what matters, and it is what licenses the frequency reading of probability from the first lesson.

Example. A measurement has standard deviation σ=1 unit. Using Chebyshev, how many repeats guarantee that the average is within 0.05 units of the true value with probability at least 0.96?

The bound is σ2/(nε2)=1/(n×0.0025), and setting this to 0.04 gives n=1/(0.04×0.0025)=10000 repeats. This is a guarantee for any distribution whatsoever, which is why it is so demanding.

Now you. With the same σ and ε=0.1, what does Chebyshev give as the bound on the failure probability after 1000 repeats?

Answer

1/(1000×0.01)=0.1, so at least a 90 percent chance of landing within 0.1 of the true mean.

What the law does not promise

The law of large numbers is the single most misquoted result in mathematics, and the misquotation has a name: the gambler's fallacy, the belief that a run of one outcome makes the other "due".

The trials are independent. A coin that has landed tails ten times running lands heads next with probability exactly 0.5, because the coin has no memory and nothing in the mathematics says otherwise. So how does the average recover?

By dilution, not by compensation. After ten tails you are ten heads behind. Toss a thousand more times and the expected number of heads among them is 500, leaving you at 500 heads out of 1010, a fraction of 0.4950. Toss ten thousand more and it is 5000 out of 10010, or 0.4995. The deficit of ten never goes away; it is simply divided by an ever larger denominator. This is exactly the pattern in Kerrich's table from the first lesson, where the absolute surplus of heads grew while the fraction converged, and the two facts are now both consequences of operatorname{Var}(Xn)=σ2/n with operatorname{Var}(Sn)=nσ2.

The second misuse is applying the law to a small number of trials. Nothing in it says anything about ten tosses, or a hundred, or an evening at a casino. The bound weakens by a factor of n, so it says nothing useful until n is large relative to σ2/ε2.

The shape of what is left over

The weak law says the error Xn-μ shrinks. That leaves an obvious question: shrinks how, and what does it look like on the way?

The scale is already known. The standard deviation of the error is σ/n, so multiplying the error by n/σ produces something whose spread stays fixed at 1 as n grows. Equivalently, standardise the sum:

Zn=Sn-nμσn

which has mean 0 and variance 1 for every n. The central limit theorem says that as n grows, the distribution of Zn converges to the standard normal, whatever the distribution of the individual Xi was, provided only that its variance is finite.

Read that again, because it is a strange claim. The ingredients can be dice, coin tosses, exponential waiting times, incomes, anything at all with a finite variance, symmetric or skewed, discrete or continuous. Sum enough of them, standardise, and the answer is the same curve to whatever accuracy you like. The individual distribution is forgotten entirely except through its mean and variance. Laplace stated a version in 1810, Lyapunov proved it under general conditions in 1901, and the name is Pólya's, from 1920.

This explains the observation the previous lesson could not. Measurement errors are normal because each is a sum of many small independent disturbances. Heights are roughly normal because many small genetic and environmental contributions add. And de Moivre's binomial approximation is the special case where the Xi are Bernoulli trials, since a binomial variable is literally a sum of n of them.

Example. Ten fair dice are rolled and totalled. The single-die mean is 3.5 and variance 35/12, so the total has mean 35 and standard deviation 350/125.4006. Estimate P(total45) using the central limit theorem with a continuity correction, and compare with the exact value.

z=(44.5-35)/5.4006=1.7591, so the estimate is 1-Φ(1.7591)0.03928. The exact answer, computed by convolving the six-sided distribution ten times, is 0.03899. Ten dice is already enough for agreement to three decimal places.

Now you. Using the same figures, estimate the probability that the total of ten dice is at least 40.

Answer

z=(39.5-35)/5.4006=0.8332, so the estimate is 1-Φ(0.8332)0.2024. The exact value is 0.2050, so the approximation is a little over one percent low.

What a poll is actually claiming

The most familiar application is the reported margin of error on an opinion poll, and it is now derivable in full.

Poll n people independently, each supporting a proposition with unknown probability p. The count is binomial, and the observed proportion pˆ has mean p and standard deviation p(1-p)/n. That quantity is largest at p=0.5, where it equals 0.5/n, so using the worst case costs little and needs no knowledge of p. By the central limit theorem pˆ is approximately normal, and 95 percent of a normal distribution lies within 1.96 standard deviations of its mean. Hence with probability about 0.95,

|pˆ-p|1.96×0.5n=0.98n

For n=1000 this is 0.031, the familiar "plus or minus three points". Quadrupling the sample to 4000 halves it to 1.55 points, which is the square root law again and is why polls are not larger: the fourth thousand respondents buy far less than the first thousand.

Two honest caveats. The figure assumes a genuine random sample, and in practice non-response and coverage errors dwarf the sampling error this formula describes, so a poll's real uncertainty is wider than its stated margin. And the margin is a statement about the procedure, not about this particular poll: one poll in twenty is expected to fall outside its own margin, which is worth remembering when a single surprising result appears.

Example. A poll of 2000 people is conducted. What is the worst-case 95 percent margin of error?

0.98/2000=0.0219, about 2.2 percentage points.

Now you. How many people must be polled for a worst-case margin of 1 percentage point?

Answer

Set 0.98/n=0.01, so n=98 and n=9604 people.

Where the limit laws fail

Both theorems have conditions, and each condition fails somewhere real.

Independence is the first. Correlated observations do not average out at the rate σ/n, and if the correlation does not decay with distance they may not average out at all. Sampling a thousand people from one town is not sampling a thousand people from the country, and treating it as such gives a margin of error that is confidently too small.

A finite variance is the second, and its failure is more dramatic. The Cauchy distribution, which describes the horizontal position where a randomly angled beam from a point source meets a line, has no finite mean or variance. The average of n independent Cauchy variables has exactly the same distribution as a single one, no matter how large n is. Averaging accomplishes literally nothing, and no amount of data helps. Real heavy-tailed data, in insurance and finance, sits between this extreme and the well-behaved case, and it converges slowly enough that the normal approximation misleads at the sample sizes people actually have.

The third is a matter of rate rather than of validity. The theorem says the limit is normal, and says nothing about how large n must be for the approximation to be usable. For a symmetric ingredient like a die, ten is plenty. For a heavily skewed one, hundreds or thousands may not be, and the tails converge far more slowly than the centre, which is precisely where the answer usually matters.

The machinery of the subject is now complete: sample spaces, conditioning, inversion, quantities, spread, the standard laws, and the limit theorems that connect them back to observation. What remains is the reliable business of applying it wrongly, which is the last lesson.

Where intuition fails

The machinery of this course is complete and correct, and it is misapplied constantly, in courtrooms, in laboratories and in ordinary judgement. Each failure below has cost real people something, each is a specific rule from an earlier lesson being skipped, and each has a check that takes under a minute. This is the lesson that makes the rest usable outside an exam.

Ignoring the base rate

The first failure is already familiar. A test that is right nine times in ten, applied to a condition present in one person in a hundred, produces mostly false positives, and the Bayes lesson computed the classic case: physicians shown a positive mammogram estimated 75 percent when the answer was 7.7 percent.

The pattern is more general than testing. Whenever you assess how likely a hypothesis is given some evidence, and reason only from how well the hypothesis explains the evidence, the base rate has been dropped. Someone quiet and tidy who likes order is more representative of a librarian than of a farmer, and there are far more farmers, so the probability calculation runs opposite to the resemblance. The evidence has to be weighed against how common the alternatives are, which is exactly what the denominator of Bayes' theorem does.

The check: state the prior odds out loud before looking at the evidence, or restate the problem in whole people out of ten thousand. Both make the size of the comparison group visible, and the size of the comparison group is the thing being forgotten.

Example. A city has 1000 terrorists among 10 million residents. A surveillance system flags 99 percent of terrorists and 1 percent of everyone else. Someone is flagged. What is the probability they are a terrorist?

True positives: 1000×0.99=990. False positives: 9999000×0.01=99990. So the probability is 990/(990+99990)0.0098, under one percent, and the system generates a hundred false alarms for every real one.

Now you. The same system is improved so that it flags only 0.1 percent of non-terrorists, with the same 99 percent detection rate. What is the probability now?

Answer

False positives fall to 9999, so the probability is 990/(990+9999)0.0901, about nine percent. A tenfold improvement in specificity still leaves nine false alarms in ten.

The prosecutor's fallacy

Confusing P(E|H) with P(H|E) has a name in law, and a famous case. In 1999 Sally Clark was convicted of murdering her two infant sons. The paediatrician Roy Meadow testified that the chance of two cot deaths in a family like hers was about 1 in 73 million, obtained by squaring a single-death rate of 1 in 8543: 85432=72982849.

Two errors, one of them the subject of this lesson. The first is that squaring assumes the two deaths independent, and they are not: siblings share genes, environment and sleeping arrangements, so a family that has suffered one cot death is at raised risk of another. The Royal Statistical Society said so publicly in October 2001.

The second error is the fallacy proper. Even granting the figure, 1 in 73 million is P(two cot deaths|innocent), and the question before the court is P(innocent|two infant deaths). Bayes says the second depends on the rarity of the alternative, and double infant murder by a mother is also extremely rare. Ray Hill's 2004 analysis of English birth and death records estimated that double cot death is between 4.5 and 9 times more likely than double murder, so the likelihood ratio points towards innocence before any other evidence is considered. Clark's conviction was quashed in January 2003, after she had served more than three years. She died in 2007.

The check: whenever a small probability is quoted about evidence, ask "small compared with what?" A number of the form P(E|H) says nothing on its own; only the ratio to P(E|alternative) carries information, which is the whole content of the odds form of Bayes' theorem.

Regression to the mean

Francis Galton measured the heights of parents and their adult children and published the result in 1886. Tall parents had tall children, but on average less tall than themselves; short parents had short children, less short than themselves. He called it regression towards mediocrity and thought he had found a biological force pulling the population back to average.

There is no force. Any measurement that is part signal and part noise behaves this way. An extreme value is extreme partly because the underlying quantity is extreme and partly because the noise happened to point the same way, and the noise does not repeat. So the second measurement is closer to the mean, mechanically, with no explanation required.

The consequence is that regression gets mistaken for cause everywhere. Israeli flight instructors, in an example Daniel Kahneman recounts, observed that pilots praised after an unusually good landing did worse next time, and pilots criticised after a bad one did better, and concluded that criticism works and praise backfires. Both groups were simply regressing. The same trap catches the patient who took a remedy at their worst and improved, the school placed in special measures after a bad year, and the fund manager hired after a spectacular one.

The check: before attributing a change to an intervention, ask whether the group was selected for being extreme on a noisy measure. If it was, some improvement was guaranteed, and the intervention has to beat that baseline rather than beat zero. A control group selected the same way is what settles it.

Example. A test has a true-score component and independent noise of equal variance. Students are selected for scoring in the top few percent, then retested. Should their average score fall?

Yes. Their high score came partly from a high true score and partly from favourable noise, and the noise is redrawn on retest with mean zero. The expected retest score sits between the selection score and the population mean, so the average must fall, with no learning, forgetting or coaching involved.

Now you. A hospital sees an unusually high infection rate one month, introduces a new hand-washing policy, and finds the rate lower the next month. What is the flaw in concluding that the policy worked?

Answer

The month was selected for being extreme on a noisy measure, so a fall was expected regardless. Concluding anything requires comparison with a similar unit that did not adopt the policy, or a longer run of data.

Looking in many places at once

Run one test at the conventional five percent threshold and there is a one in twenty chance of a false positive. Run twenty independent tests and, if nothing is really there, the probability of at least one "significant" result is

1-0.95200.6415

so a false positive is the likely outcome, not the unlikely one. At a hundred tests it is 0.9941, effectively certain, and the expected number of false positives is 100×0.05=5.

This is the union bound of the second lesson, doing its usual work: the chance that at least one of many independent unlikely things happens is much larger than any of them individually. It is why testing twenty colours of sweet against acne and reporting the one that came out significant is a fraud even when every individual calculation is correct, and why the same practice under a respectable name, trying several outcome measures and reporting the best, produced a decade of published results that would not replicate.

The two standard repairs both come out of the same arithmetic. Divide the threshold by the number of tests, so twenty tests each at 0.05/20=0.0025 keep the overall false positive rate near five percent, which is the Bonferroni correction and is exactly the union bound read backwards. Or state in advance which single test is the one that counts, so that there is nothing to correct for.

Example. A researcher runs 5 independent tests at the 0.05 threshold on data with no real effect. What is the probability that at least one comes out significant?

1-0.9550.2262, so nearly a quarter of such studies would report a finding.

Now you. How large must the number of independent tests be before that probability exceeds one half? Try a few values.

Answer

1-0.95130.4867 and 1-0.95140.5123, so fourteen tests suffice.

Counting only what came back

In 1943 the US Navy asked Abraham Wald's group to work out where to add armour to bombers, having recorded where returning aircraft had been hit: mostly on the wings and fuselage, rarely on the engines. The obvious reading is to armour the wings.

Wald's answer was the opposite. The data came only from aircraft that returned. Hits are presumably spread fairly evenly, so the near-absence of engine hits among survivors means engine hits are what stops an aircraft coming back. Armour the engines.

This is conditioning, and the failure is forgetting what the sample was conditioned on. The observed distribution is P(hit location|returned) and the useful quantity is P(shot down|hit location), which is the same inversion Bayes handles and the same one the prosecutor's fallacy botches. The pattern recurs wherever a sample is produced by a filter: successful companies studied for their common habits, when the failures had the same habits; a treatment that looks good because the patients it killed left the trial; a fund family whose average return excludes the funds that were closed.

The check: ask what would have had to happen for a case to appear in this data, and whether that condition is related to the thing being measured. If it is, the sample answers a different question from the one being asked.

Coincidences are common

The last failure is treating a coincidence as evidence, and the correction is the birthday problem generalised.

The chance that a specific named person shares your birthday is 1/365. The chance that some pair among twenty-three people shares one is 0.5073, because there are 253 pairs. Whenever an event is unlikely for each particular case, but there are a great many cases, the event becomes likely somewhere. Persi Diaconis and Frederick Mosteller called this the law of truly large numbers in 1989: with a large enough sample, any outrageous thing is likely to happen.

Put numbers on it. Something with a one in a million chance of happening to a given person on a given day happens to about 67 people a day in a country of 67 million, and about 24000 times a year. Lottery winners who win twice make headlines and are close to inevitable: Diaconis and Mosteller estimated that some double winner somewhere is essentially certain over a period of a few years, given how many people buy how many tickets, and Evelyn Adams of New Jersey duly won twice, in 1985 and 1986.

The mistake is the selection again. The coincidence was not specified in advance, and the number of ways something surprising could have happened is enormous. A probability computed after choosing which pattern to be surprised by is not a probability of anything.

The check: ask how many opportunities there were, and how many different coincidences would have struck you as remarkable. Multiply. The answer is usually that the surprising thing was due.

The habit underneath all of them

Six failures, and one shape. In every case a probability was computed conditional on something that was quietly dropped: the base rate, the alternative hypothesis, the noise in the measurement, the number of tests, the filter on the sample, the number of opportunities.

The habit that catches all six is to say out loud what the sample space is and what has been conditioned on, before computing anything. That is not a rhetorical flourish; it is the first lesson of this course, in the same order it was taught. Write the space, write what is known, and only then apply a rule. Every failure above survives only while the conditioning stays implicit, and none of them survives being written down.

A finisher of this subject can build a sample space, condition on what is known, invert with Bayes, name the distribution a mechanism produces, compute a mean and a spread, and say what a limit theorem does and does not license. The remaining work is statistics, which is this machinery run backwards: not what data a known mechanism produces, but what mechanism an observed set of data implies. That is a different subject, and it is not attemptable without this one.

Probability, from libre.university