A probability is a measure of total size 1 on a family of events, like length or area but for chance. Three axioms are enough to prove every rule of probability, to define densities, expectation and variance, and to prove that averages settle down.
Apostol, not taughtBeyond the courseApostol Vol. 2, ch. 13 (13.1 to 13.3, 13.5 to 13.7, 13.12 to 13.16, 13.21) and ch. 14 (14.1 to 14.14, 14.25 to 14.29)Kolmogorov, Grundbegriffe der Wahrscheinlichkeitsrechnung (1933)Anderson, Seppäläinen and Valkó, Introduction to Probability (the MATH 431 text)Shafer and Vovk, The Sources of Kolmogorov's Grundbegriffe (2006)
In school, the probability of an event was “favourable outcomes over total outcomes”. That works for a die. It fails for a dart thrown at a board (no outcome count), for “toss a coin until it lands heads” (no largest number of tosses), and for “pick a real number between 0 and 1 at random” (uncountably many outcomes, each with chance 0). The fix, found in the first third of the twentieth century, is to stop counting and to treat probability the way we already treat length, area and mass: as a number attached to sets, which adds up over non-overlapping pieces. This chapter builds probability on that idea, proves every familiar rule from three axioms, and finishes with the first great theorem of the subject, the law of large numbers.
Before you start
0.3: sets, unions, intersections and complements, and countable sets. 1.5: the Riemann integral and the fundamental theorem of calculus. 1.6: series and the geometric series. You do not need any earlier probability: the counting rules from JEE and CBSE are used only in examples, and every probability rule is proved from the axioms.
Quick checkWhich of these sets is countable?
Pairs of counting numbers can be listed one after another (the zig-zag of 0.3). The interval [0,1] and the set of infinite 0-1 sequences are both uncountable, by Cantor's diagonal argument.Review: pairs are countable
Quick checkWhat is 21+41+81+161+⋯?
The partial sums are 1−2−n, which tend to 1. This is the geometric series with ratio 21.Review: the geometric series
Probability is how much of a total mass of 1 sits on a set. Roll a die and the mass is 61 on each face. Measure a continuous quantity, such as the waiting time for a bus, and the mass is smeared along the line. The density says how thickly: the area under the density curve over an interval is the mass on that interval. The picture below draws random samples as a histogram, with bars scaled so that their total area is 1, and lays the density curve on top. Set the interval [a,b) with the two sliders. The page reads the probability of that interval two ways: as the fraction of samples that landed in it, and as the area under the curve. Slide the sample size n up from 10 to 30000 and watch the two numbers, and the bars and the curve, come together. That coming together is the law of large numbers, proved at the end of this chapter.
Two things to watch. Move a and b together until the interval is very thin: the area, and the fraction, both go to 0. A single point has probability 0 even though it can happen. And try “Uniform on [0, 1]”: its density is the constant 1, so the probability of an interval is its length. Length is the first and oldest example of the thing this chapter studies.
The idea, in words
Length, area, volume, mass, and the number of elements in a finite set share three properties. They are never negative. The empty set has size 0. And the size of a set made of two non-overlapping pieces is the sum of the sizes of the pieces. A probability is another example with one extra demand: the whole space has size 1.
Probability language
Set language
the sample space Ω: all outcomes that could happen
the whole space
an outcome ω
a point of Ω
an event A: “something happened”
a subset of Ω
”A or B”
the union A∪B
”A and B”
the intersection A∩B
“not A”
the complement Ac
A and B cannot both happen
A∩B=∅ (disjoint)
“if A happens then B happens”
A⊆B
Why· The core intuition: chance is mass that adds over non-overlapping pieces
If two events cannot both happen, the chance that one of them happens is the sum of their chances. Everything else, every rule in a probability course, is this one rule plus the facts that chances are never negative and that something always happens. In the picture: cut the area under the density into two non-overlapping intervals and the two areas add to the area of the union.
Where this came from· From gambling letters to measure theory
In 1654 Blaise Pascal and Pierre de Fermat exchanged letters about the problem of points: how should the stakes of an interrupted game be split? The Chevalier de Méré had brought them the problem. Their correct answer, found by counting how the game could have continued, is usually taken as the start of probability as mathematics. Jacob Bernoulli proved the first law of large numbers (his “golden theorem”), and it appeared in his book Ars Conjectandi in 1713, eight years after he died. Thomas Bayes’s essay, edited by Richard Price, appeared in 1763. All of this counted equally likely cases, which breaks for a point chosen on a line. Around 1900, Émile Borel and Henri Lebesgue built the theory of measuring sets of reals, and in 1933 Andrey Kolmogorov used it to give probability the three axioms below.
The chapter answers six questions in order. (1) What is a size that adds over disjoint pieces, and which sets can it measure? (2) What exactly are the axioms, and what do they prove? (3) How do we update a chance when we learn something, and what does independence mean? (4) How do we attach numbers to outcomes, and describe their spread? (5) What are the average and the typical spread of such numbers? (6) Why do averages of many repeated trials settle down?
Definitions and theorems
Set functions that add (Apostol 13.2 and 13.3)
Definition A
Finitely additive set function
Let A be a family of subsets of a set S. A function f that assigns a real number f(A) to every A in A is called a set function. It is finitely additive if
f(A∪B)=f(A)+f(B)whenever A,B∈A,A∩B=∅,and A∪B∈A.
Apostol 13.2 calls this the definition of a finitely additive set function. The family A is the domain of f: the sets f is allowed to measure.
In one lineA function f that gives a real number f(A) to each set A in a family of sets, so that f(A∪B)=f(A)+f(B) whenever A and B are disjoint.
Why it existsLength, area, mass and counting all add over non-overlapping pieces. This is the one property they share, and probability is built on it.
For the rule to be usable we want the union, intersection and complement of sets in the family to stay in the family. That is the next definition.
Definition A
Boolean algebra of sets
A non-empty family A of subsets of S is a Boolean algebra if A∈A and B∈A imply A∪B∈A and Ac∈A. It then also contains A∩B=(Ac∪Bc)c (De Morgan’s law, 0.3), the difference A∖B=A∩Bc, the empty set (∅=A∩Ac) and the whole set S (S=A∪Ac). The smallest example is {∅,S} and the largest is the family of all subsets of S.
In one lineA non-empty family of subsets of a set S that contains the union A∪B and the complement Ac=S∖A whenever it contains A and B.
Why it existsIt is the smallest family in which you can still say 'or' and 'not' about events, so a set function defined on it can be asked about every combination of its members.
Definition A
Finitely additive measure
A finitely additive set function f on a Boolean algebra is a finitely additive measure (Apostol calls it a “measure”) if f(A)≥0 for every A in its domain.
In one lineA finitely additive set function on a Boolean algebra that never takes a negative value.
Why it existsLength, area, mass and counting are never negative. Adding that to additivity gives the properties that the next theorem lists, and probability will be a finitely additive measure of total size 1.
Worked example Apostol 13.3, the counting example
Let S = {1, 2, 3} and let the domain be all 8 subsets. Is f(A) = (number of elements of A) a finitely additive measure? Is g(A) = (number of elements of A) squared?
Solution.
Test f on disjoint sets. If A has k elements, B has m elements and they share none, then A∪B has k+m elements, so f(A∪B)=f(A)+f(B). Counting elements in two non-overlapping piles gives the total of the two counts.
Check the sign. A count is never negative. This is the extra condition that turns additive into a measure.
Test g on one pair. Take A={1} and B={2}. They are disjoint, and g(A∪B)=22=4, but g(A)+g(B)=1+1=2. One failing pair is enough to show a rule is not additive.
Answer.f is a finitely additive measure, the counting measure. g is non-negative but not additive, so it is not a measure.
Theorem AApostol Thm 13.1
Additivity for overlapping sets
Let f be finitely additive on a Boolean algebra A and let A,B∈A. Then
f(A∪B)=f(A)+f(B∖A),f(A∪B)=f(A)+f(B)−f(A∩B).
In one lineIf f is finitely additive on a Boolean algebra, then f(A∪B)=f(A)+f(B∖A) and f(A∪B)=f(A)+f(B)−f(A∩B) for all A,B in the algebra.
Why it is trueThe definition only handles disjoint sets. This removes that condition by cutting overlapping sets into disjoint pieces.
ProofApostol 13.2
The idea: Cut A union B into disjoint pieces, apply the definition, and subtract.
A∪B is the disjoint union of A and B∖A.
A and B∖A do not overlap, and together they make up everything in A∪B.
So f(A∪B)=f(A)+f(B∖A). This is the first formula.
The definition of finite additivity applies to these two disjoint sets, and both are in the algebra (it is closed under difference).
B is the disjoint union of B∖A and A∩B, so f(B)=f(B∖A)+f(A∩B).
B is cut into the part inside A and the part outside it, and these two parts are disjoint.
f(A∪B)=f(A)+f(B)−f(A∩B).
Solve the line above for f(B∖A) and put it into the first formula.
Theorem AApostol Thm 13.2
Properties of a finitely additive measure
Let f be a finitely additive measure on a Boolean algebra. For all A,B in the algebra:
f(A∪B)≤f(A)+f(B).
If A⊆B, then f(B∖A)=f(B)−f(A).
If A⊆B, then f(A)≤f(B) (monotone).
f(∅)=0.
In one lineFor a finitely additive measure f: f(A∪B)≤f(A)+f(B); if A⊆B then f(B∖A)=f(B)−f(A) and f(A)≤f(B); and f(∅)=0.
Why it is trueThese are the rules every size obeys: a union is at most the sum of its parts, a bigger set is at least as large, and nothing has size zero.
ProofApostol 13.3
The idea: Everything follows from the previous theorem and from the fact that f is never negative.
Part 1: subtracting a non-negative number can only make the right side smaller.
By the previous theorem f(A∪B)=f(A)+f(B)−f(A∩B), and f(A∩B)≥0 because f is a measure.
Part 2: rearrange this to f(B∖A)=f(B)−f(A).
If A⊆B then A∪B=B and B∖A is what is left. The first formula of the previous theorem reads f(B)=f(A)+f(B∖A).
Part 3: f(A)≤f(B).
f(B∖A)≥0 since f is a measure, so f(B)−f(A)≥0.
Part 4: f(∅)=f(A)−f(A)=0.
Put B=A in part 2. Then A⊆B and B∖A=∅.
Quick checkLet S be the counting numbers and let the family be all finite sets and all sets with a finite complement. Define f(A) = 0 if A is finite and f(A) = 1 if the complement of A is finite. Is f finitely additive?
Two disjoint infinite sets cannot both have a finite complement, so at most one of two disjoint sets has f = 1. If both are finite, so is the union, and 0 = 0 + 0. If one is finite and one has a finite complement, the union has a finite complement and 1 = 0 + 1. Taking the value 1 on infinite sets is allowed.
Why finite additivity is not enough: countable additivity
The set function in the quiz is a perfectly good finitely additive measure. It is also strange. Write the counting numbers as N={1}∪{2}∪{3}∪⋯, a union of countably many disjoint sets, each of size f({k})=0. Yet f(N)=1. Finite additivity says nothing about adding infinitely many pieces, and the size of the union is not the sum of the sizes. For probability we want to say things like “the chance that a coin first lands heads on toss 1, or toss 2, or toss 3, and so on, is the sum of the chances”, an infinite sum. So we demand more.
Definition A
Sigma-algebra
A family F of subsets of a set Ω is a sigma-algebra (also written σ-algebra; Apostol writes “Boolean σ-algebra”) if
Ω∈F,
A∈F implies Ac∈F,
A1,A2,A3,⋯∈F implies A1∪A2∪A3∪⋯∈F.
By De Morgan’s laws it is also closed under countable intersections, and it contains ∅, finite unions and differences, so it is a Boolean algebra. Examples: all subsets of Ω; the two-set family {∅,Ω}; and, for Ω={1,…,6} (a die), the family {∅,{1,3,5},{2,4,6},Ω}, the events you can decide if you only learn whether the roll was odd or even. The Borel sigma-algebra of the real line is the smallest sigma-algebra that contains every interval. Apostol 14.1 uses it as the family of events for sample spaces inside R.
In one lineA family F of subsets of Ω that contains Ω, the complement of each member, and the union of any countable list of members.
Why it existsIt is a Boolean algebra that is also closed under countable unions, so that a set function can be asked to add up infinitely many pieces and the answer still makes sense.
The members of F are the sets we promise to measure. For a finite or countable Ω we take all subsets. For the real line we cannot, and the next theorem says why. It is a light-touch note, labelled B: nothing later depends on its proof, but you should know that the restriction is forced.
Theorem BVitali 1905
Vitali: no uniform probability on every subset
Let P be defined on all subsets of [0,1) with P([0,1))=1, with P(⋃An)=∑P(An) for disjoint sets A1,A2,…, and with P(A⊕q)=P(A) for every set A and every q, where A⊕q means every point of A moved right by q and wrapped back into [0,1) (add q then subtract 1 if the result reaches 1). Then these three requirements contradict each other.
In one lineThere is no way to assign a probability to every subset of the interval [0, 1) so that probabilities add over countably many disjoint sets, the whole interval has probability 1, and sliding a set around the circle (mod 1) never changes its probability.
Why it is trueIt shows that a sigma-algebra smaller than 'all subsets' is not a technical convenience. Any uniform random point on a line needs it.
ProofVitali's construction; uses the axiom of choice
The idea: Split [0, 1) into countably many translates of one set V. They all have the same probability, so the total is either 0 or infinity, never 1.
Cut [0,1) into equivalence classes.
Define x∼y when x−y is a rational number. This is an equivalence relation (0.4): reflexive (0 is rational), symmetric, and transitive (a sum of two rationals is rational).
Let V be a set containing exactly one point from each class.
This step uses the axiom of choice: from each of these classes (there are uncountably many) we pick one point, with no rule that says which.
The sets Vq, q rational in [0,1), do not overlap.
For rational q in [0,1) the translates Vq=V⊕q are pairwise disjoint. If v⊕q=w⊕r with v,w∈V, then v−w is rational, so v∼w, so v=w (one point per class), and then q=r.
The sets Vq together fill [0,1).
Take any x∈[0,1). It is equivalent to the chosen point v of its class, so x−v is rational, and x=v⊕q for a rational q in [0,1).
1=P([0,1))=∑qP(Vq)=c+c+c+⋯.
There are only countably many rationals (0.3), so countable additivity applies. Each Vq has the same probability c=P(V) by translation invariance.
Contradiction.
If c=0 the sum is 0. If c>0 the partial sums grow past every number, so the sum is infinite. Neither equals 1.
So a uniform random point of [0,1) forces us to give up on measuring some sets. Lebesgue measure on the Borel sets (and a bit more) is consistent; the sets that cannot be measured are never needed in applications. The rest of this chapter works inside a sigma-algebra F and lets P measure its members only.
Quick checkWhat does the Vitali theorem say about picking a uniform random point of [0, 1)?
A uniform random point does exist (Lebesgue measure on the Borel sets). What fails is the wish to give every subset a probability. Single points have probability 0, not 1/n.
Kolmogorov’s axioms
Definition A
Probability measure
A probability space is a triple (Ω,F,P):
Ω, the sample space, is a non-empty set whose points ω are the possible outcomes;
F, a sigma-algebra of subsets of Ω, whose members are called events;
P, the probability measure, a function from F to the real numbers satisfying Kolmogorov’s three axioms:
P(A)≥0 for every event A;
P(Ω)=1;
(countable additivity) if A1,A2,… are events and no two overlap (Ai∩Aj=∅ for i=j), then P(A1∪A2∪⋯)=∑i=1∞P(Ai).
In one lineA function P on a sigma-algebra F of subsets of Ω with P(A)≥0, P(Ω)=1, and P(A1∪A2∪⋯)=P(A1)+P(A2)+⋯ for disjoint A1,A2,….
Why it existsThree short rules that every probability must obey, from which all the others (complement, inclusion-exclusion, continuity) are proved.
Where this came from· Kolmogorov's Grundbegriffe, 1933
Before 1933 several definitions of probability competed: equally likely cases, long-run frequencies, degrees of belief. Andrey Kolmogorov’s monograph Grundbegriffe der Wahrscheinlichkeitsrechnung (“Basic concepts of probability theory”) settled the mathematics by giving the axioms above, built on measure theory as Borel and Lebesgue had developed it around 1900 for length and area. The elements were already around: Borel had used countable additivity in 1909, and others had treated probability as a measure. Kolmogorov put them in one clean frame and showed that the standard theorems of probability, including the laws of large numbers, follow. He also kept the philosophy short: the axioms say nothing about what chance means in the world, only how chances must fit together. Shafer and Vovk’s 2006 article, in the Watch list, traces who contributed which piece.
Dice, coins and darts are all examples of the same definition.
Finite equally likely outcomes.Ω={1,…,6}, F is all subsets, P(A)=∣A∣/6. This is the counting measure of the Example above, divided by 6 so that the total is 1.
Countably many outcomes. Toss a coin until the first head: Ω={1,2,3,…}, and P({k})=2−k. The probabilities add to ∑k≥12−k=1 (geometric series), and P(A)=∑k∈A2−k.
A uniform point of an interval.Ω=[0,1], F the Borel sets, and P gives each interval its length. An interval [a,b] has P=b−a, and a single point has P=0.
Now the work: what do the axioms prove? First, they imply finite additivity, so Apostol’s Theorems 13.1 and 13.2 apply to P at once.
Theorem AApostol 13.5 to 13.7; Kolmogorov 1933
Basic rules of probability
Let (Ω,F,P) be a probability space and A,B∈F. Then
P(∅)=0.
If A∩B=∅ then P(A∪B)=P(A)+P(B) (finite additivity); the same for any finite list of disjoint events.
P(Ac)=1−P(A).
If A⊆B then P(B∖A)=P(B)−P(A) and P(A)≤P(B).
0≤P(A)≤1.
P(A∪B)=P(A)+P(B)−P(A∩B).
In one lineFrom the three axioms: P(∅)=0; probability is finitely additive; P(Ac)=1−P(A); A⊆B implies P(A)≤P(B); every P(A) lies in [0,1]; and P(A∪B)=P(A)+P(B)−P(A∩B).
Why it is trueThese are the rules students memorize. Here each is a line or two from the axioms, so none has to be taken on trust.
ProofApostol 13.5
The idea: Pad a finite list with empty sets to use axiom 3. Then the measure theorems of the previous section apply, and the rest are one-line consequences.
Part 1: P(∅)=0.
Axiom 3 with every Ai=∅ (disjoint, and their union is ∅) gives P(∅)=P(∅)+P(∅)+⋯. This is a series of equal non-negative real terms. If the common value c were positive, the series would be at least c+c=2c>c, which cannot equal c.
Part 2: P(A∪B)=P(A)+P(B).
For disjoint A,B use axiom 3 with the list A,B,∅,∅,… and use part 1: the infinite sum is P(A)+P(B)+0+0+⋯. A longer finite list works the same way.
Part 3: P(Ac)=1−P(A).
A and Ac are disjoint with union Ω. By part 2 and axiom 2, P(A)+P(Ac)=P(Ω)=1.
Parts 4 and 6 are those theorems.
By part 2, P is a finitely additive measure on the Boolean algebra F (axiom 1 gives non-negativity). So Theorems 13.1 and 13.2 above apply to it.
Part 5: 0≤P(A)≤1.
P(A)≥0 is axiom 1. A⊆Ω, so by part 4 P(A)≤P(Ω)=1.
Worked example
Events A, B, C have P(A) = 0.5, P(B) = 0.4, P(C) = 0.3, P(A ∩ B) = 0.2, P(A ∩ C) = 0.1, P(B ∩ C) = 0.15 and P(A ∩ B ∩ C) = 0.05. Find the chance that at least one happens, and the chance that none does.
Solution.
Write the union of two pieces.A∪B∪C=(A∪B)∪C. The two-set formula only handles two sets, so treat A∪B as one.
Apply the two-set formula.P(A∪B∪C)=P(A∪B)+P(C)−P((A∪B)∩C). Rule 6 of the theorem, with A∪B in the role of A.
Expand both unions.P(A∪B)=P(A)+P(B)−P(A∩B), and (A∪B)∩C=(A∩C)∪(B∩C), whose two pieces overlap exactly in A∩B∩C. So P((A∪B)∩C)=P(A∩C)+P(B∩C)−P(A∩B∩C). Rule 6 again, twice.
Combine.P(A∪B∪C)=P(A)+P(B)+P(C)−P(A∩B)−P(A∩C)−P(B∩C)+P(A∩B∩C). Collect the terms: add the singles, subtract the pairs, add the triple.
Put in the numbers.0.5+0.4+0.3−0.2−0.1−0.15+0.05=0.8. 1.2−0.45+0.05.
None happens. The event “none” is the complement of “at least one”, so its chance is 1−0.8=0.2. Rule 3.
Answer. At least one happens with chance 0.8, and none happens with chance 0.2. Steps 1 to 4 are the proof of inclusion-exclusion for three events: it holds for any three events.
The formula in step 4 is the inclusion-exclusion formula for three events. For n events the pattern continues: add the singles, subtract the pairs, add the triples, and so on, with alternating signs. It follows by induction in the same way. MATH 431 uses it for n events; we need only the case of two and three.
Theorem ABoole's inequality; Apostol 13.7
Union bound
For events A1,A2,… (finitely or countably many), not necessarily disjoint, P(⋃nAn)≤∑nP(An).
In one lineFor any events A1,A2,…, P(A1∪A2∪⋯)≤P(A1)+P(A2)+⋯ (overlaps are counted twice, so the sum can only be too big).
Why it is trueIt lets you bound the chance that any of many bad things happens by adding up their separate chances, without knowing how they overlap.
Proofstandard
The idea: Make the events disjoint without changing their union: keep only what is new at each step. Each new piece sits inside its original event.
Let Bn be what An adds beyond A1,…,An−1.
Define B1=A1 and Bn=An∖(A1∪⋯∪An−1): the part of An not already covered. Each Bn is an event, because a sigma-algebra is closed under finite unions and differences.
The Bn are disjoint with the same union.
A point of ⋃An lies in a first An, and then it is in Bn and in no earlier Bk. So the Bn are disjoint and ⋃Bn=⋃An.
P(⋃An)=∑P(Bn).
Axiom 3 for the disjoint Bn.
∑P(Bn)≤∑P(An).
Bn⊆An, so P(Bn)≤P(An) by monotonicity (Basic rules, part 4). Adding inequalities term by term keeps the inequality.
Worked example
A server has 5 failure modes. Each one separately has probability at most 0.01 in a given day. What is the largest the chance of at least one failure can be?
Solution.
Name the events.Ai is “failure mode i happens today”, with P(Ai)≤0.01 for i=1,…,5. We know nothing about how the modes overlap, so we cannot use inclusion-exclusion.
Apply the union bound.P(A1∪⋯∪A5)≤P(A1)+⋯+P(A5)≤5×0.01. The bound needs no independence.
Answer. At most 0.05. The bound is reached exactly when the failures never happen together; if they always happen together the chance is only 0.01.
Theorem AApostol 13.21; Kolmogorov 1933
Continuity of probability
(Continuity from below.) If A1⊆A2⊆⋯ and A=⋃nAn, then limn→∞P(An)=P(A).
(Continuity from above.) If A1⊇A2⊇⋯ and A=⋂nAn, then limn→∞P(An)=P(A).
In one lineIf events grow, A1⊆A2⊆⋯, then P(An)→P(⋃An). If events shrink, A1⊇A2⊇⋯, then P(An)→P(⋂An).
Why it is trueIt says that probability of a limit is the limit of probabilities. It is where countable additivity pays off, and it is exactly what fails for the finitely additive measure above.
Proofstandard
The idea: From below, cut the growing sets into disjoint rings and add the series. From above, take complements and use the first part.
Part 1. Cut into rings.
Define B1=A1 and Bn=An∖An−1, the ring added at step n. The rings are disjoint (each point enters at one first step), B1∪⋯∪Bn=An, and ⋃Bn=A.
P(A)=∑k=1∞P(Bk).
Axiom 3 for the disjoint rings.
P(A)=limn∑k=1nP(Bk)=limnP(An).
A series is the limit of its partial sums (1.6), and finite additivity gives ∑k≤nP(Bk)=P(An).
Part 2. Pass to complements.
If the An shrink, their complements Anc grow, and by De Morgan ⋃Anc=(⋂An)c=Ac.
1−P(An)=P(Anc)→P(Ac)=1−P(A), so P(An)→P(A).
Part 1 applied to the growing complements, then P(Ec)=1−P(E) for each event.
Part 2 uses that the whole space has finite size: step 5 subtracts from P(Ω)=1. Without finiteness it is false. Count the elements of subsets of the counting numbers (a measure that can be infinite) and take An={n,n+1,n+2,…}. These shrink to the empty set, which has size 0, but every An has infinite size, so the sizes do not tend to 0. Part 1 has no such restriction.
Worked example
A fair coin is tossed forever. Find the probability that a head eventually appears.
Solution.
Name the events. Let An be “a head appears within the first n tosses”. These events grow with n.
Find P(An). The only way to avoid a head in n tosses is n tails, which has chance 2−n. So P(An)=1−2−n. Rule 3: complement of “all tails”.
Take the union.⋃An is the event “a head appears at some time”. A head at toss k puts the outcome in Ak and every later An.
Use continuity from below.P(⋃An)=limn(1−2−n)=1. The theorem above.
Answer.1. Without countable additivity (continuity) we could not pass from the chances 1−2−n to the chance of the infinite union. The finitely additive example above shows what goes wrong: it has An={n,n+1,…} shrinking to the empty set, yet f(An)=1 for all n.
Proof workshopRebuild the proof of continuity from below
Tap the lines in the order a proof would write them. Each line can only use what is already above it.
Cut the growing sets into rings that do not overlap.
Each point of A enters the sets An at a first step n and so lies in exactly one ring.
You need the rings defined before you can say what they do.
Countable additivity (axiom 3), because the rings are disjoint.
Axiom 3 applies only once you know the rings are disjoint with union A.
A series is by definition the limit of its partial sums.
This rewrites the series from the previous line.
Finite additivity, since B1∪⋯∪Bn=An is a disjoint union.
The partial sum is simplified after it has been introduced as a limit.
Substitute the previous line into the limit.
This is the conclusion, so the two lines above it come first.
Updating a chance: conditional probability, independence, Bayes
Definition A
Conditional probability
Let B be an event with P(B)>0. The conditional probability of an event A given B is
P(A∣B)=P(B)P(A∩B).
Picture the sample space as a region of total area 1. Learning that B happened throws away everything outside B. What is left has area P(B), so we divide by P(B) to make the remaining region have area 1 again. The part of A still alive is A∩B.
In one lineP(A∣B)=P(A∩B)/P(B): the chance of A once we know that B happened, defined when P(B)>0.
Why it existsNew information shrinks the sample space to B, and the chances inside B are rescaled so that they add to 1 again.
Theorem AApostol 13.12
Conditional probability is a probability measure
Let P(B)>0 and Q(A)=P(A∣B). Then Q is a probability measure on (Ω,F).
In one lineFor fixed B with P(B)>0, the function A↦P(A∣B) satisfies the three axioms, so every rule proved for P holds for it.
Why it is trueIt saves work: complement, inclusion-exclusion and continuity are true for conditional probabilities without a new proof.
ProofApostol 13.12
The idea: Check the three axioms; countable additivity transfers because intersecting disjoint sets with B keeps them disjoint.
Axiom 1: Q(A)≥0.
A ratio of the non-negative number P(A∩B) by the positive number P(B).
Axiom 2: Q(Ω)=P(B)/P(B)=1.
Ω∩B=B.
Axiom 3: for disjoint Ai, Q(⋃Ai)=P(B)P(⋃(Ai∩B)).
If A1,A2,… are disjoint then so are A1∩B,A2∩B,…, and (⋃Ai)∩B=⋃(Ai∩B).
=∑iP(B)P(Ai∩B)=∑iQ(Ai).
Countable additivity of P for the disjoint events Ai∩B, then divide each term by P(B).
Rearranging the definition gives the multiplication ruleP(A∩B)=P(A∣B)P(B) and, applying it twice, P(A∩B∩C)=P(A)P(B∣A)P(C∣A∩B) (when the events being conditioned on have positive probability).
Theorem AApostol 13.12
Law of total probability
Let B1,B2,… be a finite or countable list of disjoint events whose union is Ω (a partition of the sample space), each with P(Bi)>0. Then for every event A, P(A)=∑iP(A∣Bi)P(Bi).
In one lineIf B1,B2,… are disjoint events with union Ω and each P(Bi)>0, then P(A)=∑iP(A∣Bi)P(Bi).
Why it is trueIt computes a chance by splitting into cases, the way you do when you say 'first suppose it came from machine 1'.
Proofstandard
The idea: Cut A along the partition and add.
A=⋃i(A∩Bi) and the pieces are disjoint.
Every outcome of A lies in exactly one Bi.
P(A)=∑iP(A∩Bi).
Axiom 3.
=∑iP(A∣Bi)P(Bi).
The multiplication rule applied to each term.
Theorem ABayes 1763; Apostol 13.12
Bayes' theorem
Let B1,B2,… be a partition of Ω with all P(Bi)>0 and let A be an event with P(A)>0. Then
P(Bj∣A)=∑iP(A∣Bi)P(Bi)P(A∣Bj)P(Bj).
In one lineWith a partition B1,B2,… as above and P(A)>0: P(Bj∣A)=∑iP(A∣Bi)P(Bi)P(A∣Bj)P(Bj).
Why it is trueIt reverses the direction of conditioning: from 'how likely is the evidence if this cause is true' to 'how likely is this cause given the evidence'.
Proofstandard
The idea: Write P(A and B_j) in two ways, and expand the denominator by total probability.
P(A∩Bj)=P(Bj∣A)P(A)=P(A∣Bj)P(Bj).
The multiplication rule, used with the roles of A and Bj in both orders.
P(Bj∣A)=P(A)P(A∣Bj)P(Bj).
Divide by P(A)>0.
P(A)=∑iP(A∣Bi)P(Bi), which gives the formula.
Law of total probability for P(A).
Worked example
Machines 1, 2 and 3 make 50%, 30% and 20% of a factory's parts. Their defect rates are 1%, 2% and 3%. A part is found defective. What is the chance it came from machine 1?
Solution.
Name the events.Bi is “the part came from machine i”, with P(B1)=0.5, P(B2)=0.3, P(B3)=0.2. D is “the part is defective”, with P(D∣B1)=0.01, P(D∣B2)=0.02, P(D∣B3)=0.03. The machines are a partition: every part has exactly one maker.
Total probability of a defect.P(D)=0.5(0.01)+0.3(0.02)+0.2(0.03)=0.005+0.006+0.006=0.017. Split the defective parts by machine.
Apply Bayes.P(B1∣D)=0.0170.005=175. The numerator is the share of defects that come from machine 1.
Check. The other two posteriors are 176 and 176, and 175+176+176=1. Given a defect, the cause must be one of the three machines.
Answer.5/17≈0.294. Machine 1 makes half the parts but only 29% of the defects, because it is the most careful.
Your answerIn the factory example, what is the chance a defective part came from machine 3?
The numerator is P(D | B3) P(B3). The denominator is 0.017.
P(B3∣D)=0.0170.2×0.03=0.0170.006=176.
Quick checkA test is 99% accurate in both directions (it flags 99% of sick people and clears 99% of healthy people). One person in 1000 is sick. A random person tests positive. Roughly how likely are they to be sick?
Out of 100000 people, 100 are sick and 99 of them test positive. Of the 99900 healthy people, 1% (999) also test positive. So about 99 of 1098 positives are sick: roughly 9%. P(positive∣sick) and P(sick∣positive) are different numbers, and the base rate separates them.Review: Bayes' theorem
Definition A
Independent events
Events A and B are independent if P(A∩B)=P(A)P(B). If P(B)>0 this says P(A∣B)=P(A): knowing B does not change the chance of A. Events A1,…,An are mutually independent if for every choice of indices i1<⋯<ik (k≥2), P(Ai1∩⋯∩Aik)=P(Ai1)⋯P(Aik). They are pairwise independent if this holds only for k=2.
In one lineEvents A and B are independent when P(A∩B)=P(A)P(B). Several events are mutually independent when this product rule holds for every sub-collection.
Why it existsIt captures 'learning one tells nothing about the other': when P(B) is positive, independence means P(A | B) = P(A).
Worked example
Toss two fair coins. A = first coin heads, B = second coin heads, C = the two coins agree. Show that A, B, C are pairwise independent but not mutually independent.
Solution.
List the sample space. HH, HT, TH, TT, each with chance 41. A={HH,HT}, B={HH,TH}, C={HH,TT}. Four equally likely outcomes; each event is two of them.
Single chances.P(A)=P(B)=P(C)=21. Each event has two of the four outcomes.
Pairs.A∩B={HH}, A∩C={HH}, B∩C={HH}, each with chance 41=21⋅21. The product rule holds for each pair, so the events are pairwise independent.
The triple.A∩B∩C={HH} has chance 41, but P(A)P(B)P(C)=81. The product rule fails for the three together.
Answer. Pairwise independent, not mutually independent. Knowing A and B together determines C completely, although any two of the three say nothing about each other.
Theorem AApostol 13.13
Complements of independent events
If P(A∩B)=P(A)P(B), then P(A∩Bc)=P(A)P(Bc).
In one lineIf A and B are independent, so are A and Bc, Ac and B, and Ac and Bc.
Why it is trueIt says that independence is about the pair of questions, not about which answer you call success.
ProofApostol 13.13
The idea: Split A along B and subtract.
P(A∩Bc)=P(A)−P(A∩B).
A is the disjoint union of A∩B and A∩Bc.
=P(A)−P(A)P(B).
The independence hypothesis.
=P(A)(1−P(B))=P(A)P(Bc).
Factor, and use P(Bc)=1−P(B).
The other two statements follow by applying this one again with the roles swapped, then with Bc in place of B.
Quick checkA fair die is rolled once. A is 'the roll is 1' and B is 'the roll is 2'. Are A and B independent?
They cannot both happen, so P(A∩B)=0. Independence needs P(A∩B)=P(A)P(B)=361. Never overlapping is the opposite of independent: if A happened, B certainly did not, so learning A changes the chance of B from 61 to 0.Review: independent events
Quick checkA fair coin has landed heads 10 times in a row. What is the chance of heads on the next toss?
Independence means the earlier tosses carry no information about the next one: P(head∣10 heads before)=P(head)=21. If you doubt the coin is fair, that is a different model, in which the coin's bias is itself uncertain.
Numbers from outcomes: random variables and distribution functions
Definition A
Random variable
A random variable on (Ω,F,P) is a function X:Ω→R such that for every real x the set {ω:X(ω)≤x} is an event (belongs to F). We write this set as {X≤x} and its probability as P(X≤x). Because a sigma-algebra is closed under countable operations, sets like {a<X≤b}, {X=a} and {X∈an interval} are events too.
In one lineA function X from the sample space to the real numbers such that each event 'X is at most x' is in the sigma-algebra, so that it has a probability.
Why it existsIt lets us ask numerical questions (how many heads, how long to wait) and answer them with the same measure P.
A random variable is a function, not a number and not random. The randomness is in which outcome ω occurs. Example: toss a fair coin three times, Ω the 8 strings like HTH, and X(ω) the number of heads. Then {X=2}={HHT,HTH,THH} and P(X=2)=83.
Definition A
Distribution function
The distribution function (also called the cumulative distribution function, cdf) of a random variable X is FX(x)=P(X≤x), defined for every real x.
In one lineFX(x)=P(X≤x): the probability that the random variable is at most x, as a function of x.
Why it existsOne function that records every probability the variable can answer, since all other probabilities about X are built from differences of F.
Theorem AApostol 14.5 and 14.6
Properties of a distribution function
Let F=FX. Then:
If x≤y then F(x)≤F(y).
limx→−∞F(x)=0 and limx→∞F(x)=1.
limt↓xF(t)=F(x) for every x (right-continuous).
P(a<X≤b)=F(b)−F(a) for a<b.
P(X=a)=F(a)−F(a−), where F(a−)=limt↑aF(t) (this limit exists by part 1).
In one lineF is non-decreasing, tends to 0 at minus infinity and to 1 at plus infinity, is continuous from the right, satisfies P(a<X≤b)=F(b)−F(a), and has P(X=a)=F(a)−F(a−), the size of its jump at a.
Why it is trueThese are exactly the facts that let you read probabilities off a graph of F, and they are where continuity of probability from the last section is used.
Proofstandard
The idea: Parts 1 and 4 are monotonicity and finite additivity. Parts 2, 3 and 5 pass to a limit along a monotone sequence of events, using continuity of probability.
Part 1: F(x)≤F(y).
If x≤y then {X≤x}⊆{X≤y}, and probability is monotone.
Part 4: F(b)=F(a)+P(a<X≤b).
{X≤b} is the disjoint union of {X≤a} and {a<X≤b}. Finite additivity.
Part 2.
The events {X≤n} grow to Ω (every X(ω) is a real number, so it is at most n for large n). By continuity from below, F(n)→P(Ω)=1. Since F is non-decreasing and bounded by 1, the limit along all real x exists and has this value. For −∞, the events {X≤−n} shrink to ∅, and continuity from above gives F(−n)→0.
Part 3.
For tn↓x the events {X≤tn} shrink, and their intersection is {X≤x}. Continuity from above. Monotonicity of F then covers every way of approaching from the right.
Part 5: P(X=a)=F(a)−F(a−).
{X=a} is the intersection of the shrinking events {a−n1<X≤a}. Continuity from above gives P(X=a)=limn(F(a)−F(a−n1)), using part 4.
Worked example
X is the number of heads in three fair coin tosses. Write F(x), and use it to find P(X = 2) and P(0 < X ≤ 2).
Solution.
The probabilities of single values.P(X=0),P(X=1),P(X=2),P(X=3)=81,83,83,81. Counting: (k3) strings out of 8 have k heads.
Build F by adding up.F(x)=0 for x<0; 81 for 0≤x<1; 21 for 1≤x<2; 87 for 2≤x<3; 1 for x≥3. F(x) adds the probabilities of all values at most x. It is a staircase that jumps at each value.
Read the jump at 2.P(X=2)=F(2)−F(2−)=87−21=83. Part 5 of the theorem: the size of the jump.
Use differences.P(0<X≤2)=F(2)−F(0)=87−81=43. Part 4. Check by hand: P(X=1)+P(X=2)=83+83=43.
Answer.P(X=2)=83 and P(0<X≤2)=43.
Discrete and continuous distributions
Definition A
Probability mass function
A random variable X is discrete if there is a countable set S of values with P(X∈S)=1. Its probability mass function is p(x)=P(X=x). Then p(x)≥0, ∑x∈Sp(x)=1, and P(X∈A)=∑x∈Ap(x) for any set A of values, by countable additivity. Its distribution function is a staircase, as in the example above. Three discrete distributions appear everywhere.
Bernoulli(p):P(X=1)=p, P(X=0)=1−p. A single yes-or-no trial.
Binomial(n,p): the number of successes in n independent trials of chance p. Model: Ω={0,1}n with P({ω})=pk(1−p)n−k if ω has k ones. These add to (p+(1−p))n=1 by the binomial theorem. The strings with k ones number (kn), so P(X=k)=(kn)pk(1−p)n−k.
Geometric(p): the number of trials up to and including the first success. P(X=k)=(1−p)k−1p for k=1,2,… These add to p∑j≥0(1−p)j=p⋅p1=1 (geometric series, 1.6).
In one lineFor a random variable that takes only countably many values, p(x)=P(X=x). The values p(x) are non-negative and add to 1.
Why it existsWhen the mass sits on separate points, listing the mass at each point says everything.
Definition A
Probability density function
A random variable X has a probability density functionf if f(t)≥0 and, for every x,
FX(x)=P(X≤x)=∫−∞xf(t)dt.
Here ∫−∞xf means lima→−∞∫axf, the limit of ordinary Riemann integrals (1.5). For f≥0 this limit exists in [0,∞], because the integral grows as a decreases (a monotone sequence, 1.2). Write ∫−∞∞f for the whole mass. Such an integral over an unbounded interval is called an improper integral; the Riemann integral needs a bounded interval, and we take the limit.
In one lineA function f≥0 with FX(x)=∫−∞xf(t)dt for all x. Then probabilities of intervals are areas under f.
Why it existsWhen the mass is spread smoothly along the line, no single point carries any, and only the density, the mass per unit length, makes sense.
What follows from this definition, using the theorem on distribution functions and the fundamental theorem of calculus (1.5):
∫−∞∞f=limx→∞F(x)=1: the total area under a density is 1.
P(a<X≤b)=F(b)−F(a)=∫abf: probability is area.
P(X=a)=F(a)−F(a−)=0, because F is an integral and so has no jumps. Single points have probability 0.
Where f is continuous, F′(x)=f(x).
f(x) is not a probability. It is a probability per unit length and can exceed 1: the density f(x)=2 on [0,21] is legitimate, since its area is 1.
The word “continuous” needs care. A random variable can have a distribution function F with no jumps and still have no density, because F need not be an integral of anything. The Cantor function, which climbs from 0 to 1 while being flat almost everywhere, is the standard example (label B; we do not use it). When we say “a continuous random variable” in this chapter we always mean one with a density.
Worked example
Find c so that f(x) = c·x² for 0 ≤ x ≤ 2 (and 0 elsewhere) is a density. For this X, find F, P(X > 1), E[X] and Var(X).
Solution.
Set the total area to 1.∫02cx2dx=c⋅38=1, so c=83. Antiderivative x3/3 at 2 gives 8/3. A density must have area 1.
Find F. For 0≤x≤2, F(x)=∫0x83t2dt=8x3; F=0 for x<0 and F=1 for x>2. F is the area under f up to x. Check: F(2)=1.
Mean.E[X]=∫02x⋅83x2dx=83⋅424=23. Expectation of a density is ∫xf(x)dx (defined in the next section).
Second moment.E[X2]=∫02x2⋅83x2dx=83⋅525=512. Same, with x2 in place of x.
Variance.Var(X)=512−(23)2=2048−45=203. Variance is second moment minus mean squared (proved below).
Answer.c=83, P(X>1)=87, E[X]=23, Var(X)=203.
Your answerX has density f(x) = (3/8)x² on [0, 2]. What is P(X > 1)?
Integrate the density from 1 to 2, or use 1 − F(1).
F(x)=x3/8 on [0,2], so P(X>1)=1−1/8=7/8. Equivalently ∫1283x2dx=81(8−1)=87.
Quick checkIs f(x) = 2 for 0 ≤ x ≤ 1/2 (and 0 elsewhere) a valid probability density?
The rectangle has width 21 and height 2, so its area is 1. A density is a probability per unit length. It can be large where the mass is concentrated; it is the area, not the height, that must be at most 1.
Three densities are worth knowing in full (Apostol 14.10, 14.13, 14.14).
Uniform on [a,b]:f(x)=b−a1 for a≤x≤b. Area: (b−a)⋅b−a1=1. The chance of an interval inside [a,b] is its length divided by b−a.
Exponential with rate λ>0:f(x)=λe−λx for x≥0 (and 0 for x<0). The area is limb→∞∫0bλe−λxdx=limb→∞(1−e−λb)=1. It is the standard model of a waiting time. P(X>x)=e−λx.
Theorem AApostol 14.13
The exponential distribution forgets
For X exponential with rate λ and s,t≥0: P(X>s+t∣X>s)=e−λt=P(X>t).
In one lineIf X is exponential with rate λ, then P(X>s+t∣X>s)=P(X>t) for all s,t≥0.
Why it is trueHaving already waited s minutes does not shorten the remaining wait. This 'memoryless' property is why the exponential is the waiting time of events that strike without wear.
ProofApostol 14.13
The idea: Use the definition of conditional probability and P(X > x) = e^(-lambda x).
P(X>s+t∣X>s)=P(X>s)P(X>s+t).
{X>s+t}⊆{X>s}, so the intersection is {X>s+t}.
=e−λse−λ(s+t).
P(X>x)=e−λx from the density.
=e−λt=P(X>t).
The exponents subtract.
Worked example
The time until a server's next crash is exponential with mean 50 hours (so λ = 1/50 per hour). Find the chance it runs more than 80 hours before crashing, and the chance it runs more than 110 hours given that it has already run 30 without crashing.
Conditional.P(X>110∣X>30)=P(X>80)=e−1.6≈0.2019. The memoryless property with s=30 and t=80, since 110=30+80.
Answer.e−1.6≈0.202 in both cases. A server that has already run 30 hours is, as far as the next crash is concerned, as good as a freshly started one: the remaining time has the same distribution as a new server’s.
Your answerA waiting time is exponential with rate 2 per minute. What is the chance the wait exceeds 1 minute? (Give e raised to a power, or a decimal.)
Use P(X > x) = e^(−λx).
P(X>1)=e−λ⋅1=e−2≈0.1353.
Normal (Gaussian) with mean μ and variance σ2:f(x)=σ2π1e−(x−μ)2/(2σ2). The special case μ=0, σ=1 is the standard normal density φ(x)=2π1e−x2/2. That this really has area 1 is a famous computation.
Theorem BGauss; Apostol 14.14
The Gaussian integral
I=∫−∞∞e−x2/2dx is finite and equals 2π. Hence ∫φ=1, and for any μ and σ>0 the normal density with mean μ and variance σ2 also has area 1.
In one line∫−∞∞e−x2/2dx=2π, so the standard normal density has total area 1.
Why it is trueThe antiderivative of e^(-x^2/2) is not an elementary function, so the area cannot be found by the fundamental theorem directly. Squaring the integral turns it into a two-dimensional one that polar coordinates can do.
Proofstandard; uses Fubini and polar coordinates from multivariable calculus (Apostol ch. 11)
The idea: Show the integral is finite by comparison. Square it, view the product as an integral over the plane, and switch to polar coordinates, where the radial integral has an elementary antiderivative.
The integral is finite: e−x2/2≤e1/2e−∣x∣, and the area under e−∣x∣ is 2.
(∣x∣−1)2≥0 gives x2/2≥∣x∣−21, so e−x2/2≤e1/2e−∣x∣. And ∫0be−xdx≤1 for all b.
I2=∬R2e−(x2+y2)/2dxdy.
Because e−(x2+y2)/2=e−x2/2e−y2/2, the product of the two one-variable integrals is a double integral over the whole plane (Fubini's theorem, a tool from multivariable calculus that we use without proof).
=∫02π∫0∞e−r2/2rdrdθ.
Substitute x=rcosθ, y=rsinθ. The plane is covered by r≥0, 0≤θ<2π, and the area element becomes rdrdθ (change of variables in a double integral, also taken from multivariable calculus).
The inner integral is 1, so I2=2π⋅1=2π.
An antiderivative of re−r2/2 is −e−r2/2, so ∫0bre−r2/2dr=1−e−b2/2→1 as b→∞. This is the fundamental theorem of calculus (1.5).
I=2π.
I>0 because the integrand is positive, so we take the positive square root.
So the normal density with parameters μ, σ2 has area 1.
For the general case substitute u=(x−μ)/σ, dx=σdu: the factor σ2π1 times σ2π is 1.
The plane-integral step uses outside tools, which is why this theorem is labelled B. Everything else in the chapter is proved from the axioms and the one-variable integral. A numerical check is easy: the area under φ between −1.96 and 1.96 is about 0.95, and between −1 and 1 about 0.683.
Your answerFor the standard normal density, the area between −1 and 1 is about 0.6827. Using symmetry, what is the area to the right of 1 (to 3 decimal places)?
Two equal tails share what is left over.
The total area is 1. The area between −1 and 1 is 0.6827. The remaining 0.3173 is split equally between the two tails by symmetry: 0.3173/2=0.1587.
The centre and the spread: expectation and variance
Definition A
Expectation
Let X be a random variable. If X is discrete with mass function p and ∑x∣x∣p(x)<∞, its expectation (mean, expected value) is E[X]=∑xxp(x). If X has a density f and ∫−∞∞∣x∣f(x)dx<∞, then E[X]=∫−∞∞xf(x)dx. The requirement of absolute convergence is not a pedantic extra: a series that converges only conditionally can be rearranged to any sum (1.6), so the average would depend on the order of the outcomes. If the condition fails, we say E[X] does not exist. The same two formulas with g(x) in place of x give E[g(X)] (Apostol 14.26).
In one lineThe probability-weighted average of the values of X: E[X]=∑xp(x) for a discrete variable and E[X]=∫xf(x)dx for one with a density, when these converge absolutely.
Why it existsIt is the single number that the average of many repeated trials settles to, and the balance point of the mass.
Balance-point picture: put the mass on a ruler. E[X] is where the ruler balances.
Worked example
Roll a fair die and let X be the number shown. Find E[X], E[X²] and the variance.
Solution.
Mean.E[X]=61(1+2+3+4+5+6)=621=27. Each value has p(x)=61.
Second moment.E[X2]=61(1+4+9+16+25+36)=691. The formula for E[g(X)] with g(x)=x2.
Variance.Var(X)=E[X2]−E[X]2=691−449=12182−147=1235≈2.917. The variance shortcut, proved below.
Answer.E[X]=3.5 (a value the die can never show: the mean is a balance point, not a typical outcome), E[X2]=91/6, Var(X)=35/12.
Theorem AApostol 14.25 and 14.26
Linearity of expectation
Let Ω be countable, with F all subsets so that every single outcome is an event, and let X,Y be random variables with E∣X∣<∞ and E∣Y∣<∞. Then E[X+Y]=E[X]+E[Y], and E[aX+b]=aE[X]+b for constants a,b. (The same is true in general. The proof for densities uses the joint density of two variables, Apostol 14.21, which we do not develop.)
In one lineFor random variables on a countable sample space with finite expectation, E[X+Y]=E[X]+E[Y] and E[aX+b]=aE[X]+b.
Why it is trueNo independence is needed. It is the most useful rule in probability, because it lets you find an average by adding the averages of simple pieces.
Proofstandard
The idea: On a countable sample space the expectation is a sum over outcomes. Sums add, and constants pull out.
E[X]=∑xxP(X=x)=∑ωX(ω)P({ω}).
Group the outcomes by the value of X: the outcomes with X(ω)=x contribute x⋅P(X=x) in total. The series converges absolutely, so the grouping and the order do not matter (rearrangement of absolutely convergent series).
E[X+Y]=∑ω(X(ω)+Y(ω))P({ω}).
The same formula for the random variable X+Y.
=∑ωX(ω)P({ω})+∑ωY(ω)P({ω})=E[X]+E[Y].
Two absolutely convergent series can be added term by term.
E[aX+b]=a∑ωX(ω)P({ω})+b∑ωP({ω})=aE[X]+b.
Constants come out of an absolutely convergent sum, and ∑ωP({ω})=1.
Definition A
Variance
If E[X]=μ exists and E[(X−μ)2]<∞, the variance of X is Var(X)=E[(X−μ)2]. The standard deviation is σ=Var(X), in the same units as X.
In one lineVar(X)=E[(X−μ)2] with μ=E[X]: the average squared distance from the mean, a measure of spread.
Why it existsAveraging the distance itself would cancel (the signed distances average to 0). Squaring makes every deviation count, and it gives the algebra that makes Chebyshev's inequality work.
Theorem AApostol 14.25
Variance shortcut and scaling
If Var(X) exists, then Var(X)=E[X2]−μ2 with μ=E[X], and Var(aX+b)=a2Var(X).
In one lineVar(X)=E[X2]−(E[X])2 and Var(aX+b)=a2Var(X).
Why it is trueThe shortcut is the form used for every computation. The scaling rule says shifting does not change spread and stretching by a stretches the spread by a.
Proofstandard
The idea: Expand the square and use linearity of expectation.
Var(X)=E[X2−2μX+μ2].
Expand (X−μ)2=X2−2μX+μ2.
=E[X2]−2μE[X]+μ2=E[X2]−2μ2+μ2.
Linearity: μ is a constant.
=E[X2]−μ2.
Combine.
Scaling: Var(aX+b)=E[a2(X−μ)2]=a2Var(X).
E[aX+b]=aμ+b by linearity, so (aX+b)−(aμ+b)=a(X−μ).
Worked example Apostol 14.10 and 14.13
Find the mean and variance of the uniform distribution on [a, b], and of the exponential distribution with rate λ.
Solution.
Uniform mean.E[X]=∫abb−axdx=2(b−a)b2−a2=2a+b. The midpoint: the ruler balances at the middle.
Uniform second moment.E[X2]=3(b−a)b3−a3=3a2+ab+b2. b3−a3=(b−a)(a2+ab+b2).
Uniform variance.3a2+ab+b2−4(a+b)2=124a2+4ab+4b2−3a2−6ab−3b2=12(b−a)2. Common denominator 12 and the shortcut formula.
Exponential mean.∫0bxλe−λxdx=[−(x+λ1)e−λx]0b→λ1 as b→∞. Differentiate the bracket to check it is an antiderivative. The term be−λb tends to 0 because an exponential beats any power.
Exponential second moment. An antiderivative of x2λe−λx is −(x2+λ2x+λ22)e−λx, so E[X2]=λ22. Same method: integrating by parts reduces the power of x by one each time.
Exponential variance.λ22−λ21=λ21. The shortcut formula.
Answer. Uniform: mean 2a+b, variance 12(b−a)2. Exponential: mean λ1, variance λ21 (so the standard deviation equals the mean). For the normal distribution with parameters μ and σ2: the mean is μ (the density is symmetric about μ) and the variance is σ2 (integrate x2φ by parts: ∫x⋅xφ=[−xφ]+∫φ=1 for the standard case, then scale by the scaling rule).
Your answerX is uniform on [0, 6]. What is Var(X)?
Use (b − a)²/12.
Var(X)=(b−a)2/12=36/12=3.
Quick checkX has density 1/(π(1 + x²)) on the whole real line (the Cauchy distribution). Does X have an expectation?
The density is a legitimate one (its area is π1[arctanx]−∞∞=1) and symmetric, which tempts you to say the mean is 0. But ∫0bπ(1+x2)xdx=2πln(1+b2)→∞, so the integral of ∣x∣f diverges, and the mean does not exist. Absolute convergence is part of the definition.Review: expectation
To combine variances we need independent random variables.
Definition A
Independent random variables
Random variables X and Y on the same probability space are independent if for all intervals A,B of the real line the events {X∈A} and {Y∈B} are independent. For discrete variables this includes P(X=x,Y=y)=P(X=x)P(Y=y) for all values x,y. A list X1,…,Xn is independent if the events {Xi∈Ai} are mutually independent for all intervals Ai.
In one lineX and Y are independent when every event about X is independent of every event about Y: P(X∈A,Y∈B)=P(X∈A)P(Y∈B) for all intervals A, B.
Why it existsIt is independence of events transferred to numbers, and it is what lets variances of sums add.
Theorem AApostol 14.25
Variance of a sum of independent variables
Let X,Y be independent discrete random variables with finite variance. Then Var(X+Y)=Var(X)+Var(Y). The same is true for random variables with densities (Apostol 14.21 and 14.25), and by induction for any finite list of independent variables.
In one lineIf X and Y are independent discrete random variables with finite variance, then E[XY]=E[X]E[Y] and Var(X+Y)=Var(X)+Var(Y).
Why it is trueIt is why the spread of an average of n independent measurements shrinks like one over the square root of n: variances add, and the standard deviation grows only like the square root.
Proofstandard
The idea: Expand the square of X+Y minus its mean. The cross term has mean zero because, for independent variables, the mean of the product is the product of the means.
Independence gives P(X=x,Y=y)=pX(x)pY(y). The double series for E∣XY∣ converges because it factors as E∣X∣⋅E∣Y∣. A series of non-negative terms can be summed in either order, and for absolutely convergent series the same holds.
Then E[X′Y′]=E[X′]E[Y′]=0.
Let X′=X−μX and Y′=Y−μY. They are again independent (shifting does not change which events about them are independent), and E[X′]=E[Y′]=0.
Var(X+Y)=E[X′2]+2E[X′Y′]+E[Y′2].
Expand (X′+Y′)2=X′2+2X′Y′+Y′2 and use linearity. The mean of X+Y is μX+μY.
=Var(X)+Var(Y).
The middle term is 0.
Worked example
X is binomial with n = 10 and p = 0.3: the number of successes in 10 independent trials. Find E[X] and Var(X).
Solution.
Write X as a sum.X=I1+⋯+I10, where Ik=1 if trial k succeeds and 0 otherwise. Each Ik is a Bernoulli(0.3) variable, and the trials are independent.
Mean of one trial.E[Ik]=0.3. 1⋅0.3+0⋅0.7.
Variance of one trial.E[Ik2]=0.3 (since Ik2=Ik), so Var(Ik)=0.3−0.09=0.21. Shortcut formula.
Add up.E[X]=10×0.3=3 by linearity, and Var(X)=10×0.21=2.1 since variances of independent variables add. The last two theorems.
Answer.E[X]=3, Var(X)=2.1. In general, a binomial has mean np and variance np(1−p).
Chebyshev’s inequality and the law of large numbers
Variance measures spread. The next theorem makes that precise: a small variance forces the variable to stay close to its mean.
Where this came from· Chebyshev and the road to the law of large numbers
Jacob Bernoulli’s proof that relative frequencies settle near the true probability appeared in 1713 and was elaborate. The inequality below gives a short proof. Irénée-Jules Bienaymé stated it in 1853, and Pafnuty Chebyshev published a general form in 1867, using it to prove a law of large numbers; the inequality now carries Chebyshev’s name, though some authors write Bienaymé–Chebyshev. The name “law of large numbers” is Siméon-Denis Poisson’s, from the 1830s. Chebyshev’s student Andrey Markov later studied sequences whose steps depend on each other (see 2.11).
Theorem AMarkov; standard
Markov's inequality
Let Y be a random variable with Y≥0 and finite expectation, and let a>0. Then P(Y≥a)≤aE[Y].
In one lineIf Y≥0 and a>0, then P(Y≥a)≤E[Y]/a.
Why it is trueA non-negative quantity with a small average cannot often be large. It is the first step to Chebyshev.
Proofstandard
The idea: Compare Y with a times the indicator of the event 'Y at least a'. Pointwise, the second is smaller, so its expectation is smaller.
For every outcome, a1{Y≥a}(ω)≤Y(ω), where 1{Y≥a} is 1 when Y≥a and 0 otherwise.
If Y(ω)≥a, the left side is a and the right side is Y(ω)≥a. If Y(ω)<a, the left side is 0 and the right side is Y(ω)≥0.
Take expectations: aE[1{Y≥a}]≤E[Y].
Expectation preserves inequalities: if U≤V pointwise then E[U]≤E[V]. For a discrete variable the sums compare term by term, and for a density the integrals compare by monotonicity of the integral (1.5).
aP(Y≥a)≤E[Y].
The indicator takes the value 1 with probability P(Y≥a) and 0 otherwise, so its mean is P(Y≥a). Divide by a>0.
Theorem AApostol Thm 14.11
Chebyshev's inequality
Let X have mean μ and variance σ2<∞. Then for every c>0,
P(∣X−μ∣≥c)≤c2σ2.
Equivalently, with c=kσ: the chance of being at least k standard deviations away from the mean is at most 1/k2.
In one lineIf X has mean μ and finite variance, then for every c>0, P(∣X−μ∣≥c)≤Var(X)/c2.
Why it is trueIt bounds the chance of a large deviation using only the variance, without knowing the distribution. It is crude but universal, which is exactly what the law of large numbers needs.
Proofstandard
The idea: Apply Markov's inequality to the squared deviation. The event 'distance at least c' is the same as 'squared distance at least c squared'.
Let Y=(X−μ)2≥0.
Put Y=(X−μ)2. It is non-negative, and E[Y]=Var(X)=σ2 by the definition of variance.
The events {∣X−μ∣≥c} and {Y≥c2} are the same.
Squaring is an increasing function on non-negative numbers, so ∣X−μ∣≥c exactly when (X−μ)2≥c2.
P(∣X−μ∣≥c)=P(Y≥c2)≤c2E[Y].
Markov's inequality with a=c2>0.
=c2σ2.
Substitute E[Y]=σ2.
Why· The picture behind the proof
In the histogram at the top of the page, the variance is the average of the squared distance from the centre. If a lot of mass sat far out, at distance c or more, each unit of that mass would contribute at least c2 to this average, so the average would be at least c2 times the far-out mass. The variance is a fixed number σ2, which caps the far-out mass at σ2/c2. The proof says exactly this with symbols: the shaded tails count at least c2 each.
Proof workshopRebuild the proof of Chebyshev's inequality
Tap the lines in the order a proof would write them. Each line can only use what is already above it.
This is the definition of variance, and a square is never negative.
Squaring is increasing on non-negative numbers.
The variable Y has to be introduced before you can rewrite an event in terms of it.
If Y is at least c2 the left side is c2 and is at most Y; otherwise the left side is 0 and Y≥0.
This compares Y with the indicator of the event you rewrote on the previous line.
Expectation preserves inequalities, and the mean of an indicator is the probability of its event.
You need the pointwise inequality before you can take expectations of both sides.
Divide by c2>0 and use the first two lines.
This is the conclusion, so every earlier line comes first.
Worked example the method of Apostol 14.29
A fair die is rolled n times and the average of the rolls is taken. How many rolls guarantee, with probability at least 90%, that the average is within 0.1 of 3.5? Use Chebyshev. Then compare with the normal approximation.
Solution.
Set up. Let Xˉ be the average of the n rolls. E[Xˉ]=3.5 and one roll has variance 1235. Both were found in the die example above.
Variance of the average.Var(Xˉ)=n21⋅n⋅1235=12n35. Variances of independent rolls add, and dividing by n divides the variance by n2 (scaling rule).
Apply Chebyshev.P(∣Xˉ−3.5∣≥0.1)≤0.1235/(12n)=n291.67. c=0.1, so c2=0.01, and 1235÷0.01=291.67.
Make the bound at most 0.1.n291.67≤0.1 gives n≥2916.7, so n=2917. “At least 90% within” means at most 10% outside. Divide 291.67 by 0.1 and round up.
Compare with the truth. The normal approximation (the central limit theorem, Apostol 14.30) says that P(∣Z∣≤1.645)=0.90 for a standard normal Z, so we need 1.645×35/(12n)≤0.1, which gives n≥790. The standard deviation of Xˉ is 35/(12n), and a 90% band is about 1.645 standard deviations wide on each side.
Answer. Chebyshev guarantees that n=2917 rolls suffice. About 790 are really needed. Chebyshev is safe for every distribution and therefore loose for this one.
Your answerBy Chebyshev's inequality, how many rolls of a fair die make P(|average − 3.5| ≥ 0.1) at most 0.1?
The variance of the average is (35/12)/n. The bound is variance / c². Then solve bound ≤ 0.1.
Var(Xˉ)=12n35 and c=0.1, so the bound is 12n×0.0135=n291.67. Setting this at most 0.1 gives n≥2916.7, so n=2917.
Let X1,X2,… be independent random variables with E[Xi]=μ and Var(Xi)=σ2<∞, and let Xˉn=(X1+⋯+Xn)/n. Then for every ε>0 and every n,
P(∣Xˉn−μ∣≥ε)≤nε2σ2,son→∞limP(∣Xˉn−μ∣≥ε)=0.
In one lineIf X1,X2,… are independent with the same mean μ and the same finite variance σ2, then for every ε>0, P(∣Xˉn−μ∣≥ε)≤nε2σ2→0.
Why it is trueIt turns 'averages settle to the mean' into a statement with a number: the chance of an error of size epsilon after n trials is at most sigma squared over n epsilon squared.
ProofApostol 14.29
The idea: Find the mean and variance of the average, then apply Chebyshev's inequality to it.
E[Xˉn]=n1(μ+⋯+μ)=μ.
Linearity of expectation.
Var(Xˉn)=n21(σ2+⋯+σ2)=nσ2.
Variances of independent variables add, and the scaling rule divides by n2.
P(∣Xˉn−μ∣≥ε)≤ε2Var(Xˉn)=nε2σ2.
Chebyshev's inequality for the random variable Xˉn, with c=ε.
The bound tends to 0.
σ2 and ε are fixed, so σ2/(nε2)→0 as n→∞.
Our proof of the variance rule covered discrete variables; for variables with densities the same argument works with joint densities. The finite variance is a hypothesis of this proof, because Chebyshev’s inequality needs it. A finer argument, by Khinchin in 1929, shows that for independent variables with the same distribution a finite mean alone is enough. The theorem is about the chance of a deviation, not about every single run. It does not say the running average of one particular sequence stays within ε forever (that is the strong law, proved by Borel in 1909; it needs more). Nor does it say that heads must catch up after a long run of tails: independence means the past carries no information. And it needs a mean to exist. For the Cauchy distribution the average of n samples is again Cauchy, however large n is, and never settles. The lab below shows both behaviours.
Python labThe law of large numbers, and how loose Chebyshev's bound is
import numpy as npimport matplotlib.pyplot as pltrng = np.random.default_rng(7)var = 35 / 12 # variance of one fair dieeps, runs = 0.5, 20000print("n Chebyshev bound observed frequency of |mean - 3.5| >= 0.5")for n in (10, 100, 1000): means = rng.integers(1, 7, size=(runs, n)).mean(axis=1) print(f"{n:<5d} {var / (n * eps**2):<17.4f} {np.mean(np.abs(means - 3.5) >= eps):.4f}")n = 3000paths = rng.integers(1, 7, size=(4, n)).cumsum(axis=1) / np.arange(1, n + 1)for p in paths: plt.plot(p)plt.axhline(3.5, color="black", lw=1)plt.xlabel("number of rolls n"); plt.ylabel("average of the first n rolls")plt.title("Four runs of the running average of a fair die")
Try this.At n = 100 the Chebyshev bound is 0.1167 but the observed frequency of a deviation of at least 0.5 is about 0.004: about 30 times smaller. At n = 10 the bound exceeds 1, which says nothing. Now change rng.integers(1, 7, size=(4, n)) in the plot to rng.standard_cauchy(size=(4, n)) and run again. The running averages of Cauchy samples keep making large jumps even at n = 3000, because the Cauchy distribution has no mean.
Quick checkBy the weak law of large numbers, what happens to the chance that the average of n fair-die rolls differs from 3.5 by at least 0.2?
Chebyshev gives the upper bound n(0.2)235/12, which goes to 0. It never becomes exactly 0 for a finite n (a long run of sixes is possible), and it does not stay near 21.Review: the weak law
Beyond the course: for understanding· What Chebyshev cannot say: the central limit theorem
Chebyshev’s bound 1/k2 is the same for every distribution. For the average of many independent variables the truth is much smaller and has a universal shape: the average, standardized to have mean 0 and standard deviation 1, has a distribution that approaches the standard normal (Apostol 14.30). For the standardized coin average this gives about 0.0455 for a deviation of two standard deviations, where Chebyshev gives 0.25. The theorem is the reason the normal curve is everywhere, and it is the tool behind confidence intervals and the A/B test below. Its proof needs more machinery than this chapter develops.
Examples and non-examples
The worked examples sit beside the ideas they practise, above. Four short contrasts to keep straight.
Probability, not a probability.μ(A)=∣A∣ on a finite set is a measure but not a probability (the total is ∣S∣, not 1). Dividing by ∣S∣ makes it one. Length on [0,5] is a measure of total 5; dividing by 5 gives the uniform probability.
Additive, not countably additive. The finite/cofinite set function of the quiz is finitely additive and fails continuity. It is not a probability measure, since N is a countable union of sets of size 0 and has size 1.
A density, not a probability.f(x)=2 on [0,21] is a density, and f(0.1)=2 is not a probability. P(X=0.1)=0.
A mean that does not exist. The Cauchy density is symmetric, area 1, and has no mean. Variance and the law of large numbers need the mean to exist first.
Where it is used
Used inside maths· Inside maths: Bernstein polynomials prove Weierstrass's approximation theorem with Chebyshev's inequality
Weierstrass (1885) proved that every continuous function on [0,1] is a uniform limit of polynomials. Sergei Bernstein (1912) gave an explicit proof that is a law of large numbers in disguise. For f continuous on [0,1] let
Bnf(x)=k=0∑nf(nk)(kn)xk(1−x)n−k=E[f(Sn/n)],
where Sn is binomial with n trials and success chance x. So Bnf(x) is the average of f at the random point Sn/n, and by the law of large numbers Sn/n is near x with high probability.
Claim:Bnf→f uniformly on [0,1].
Proof. Let M=max∣f∣ and ε>0. By uniform continuity (1.3) pick δ>0 with ∣f(s)−f(t)∣<ε whenever ∣s−t∣<δ. Fix x and write Y=Sn/n. Then ∣Bnf(x)−f(x)∣=∣E[f(Y)−f(x)]∣≤E∣f(Y)−f(x)∣. Split into the outcomes with ∣Y−x∣<δ, where the integrand is below ε, and those with ∣Y−x∣≥δ, where it is at most 2M:
The middle step is Chebyshev with Var(Y)=x(1−x)/n; the last uses x(1−x)≤41. The bound does not depend on x, so for n>M/(2εδ2) the error is below 2ε everywhere. ■
For f(x)=∣x−21∣ the largest error is about 0.123 at n=10, 0.040 at n=100 and 0.0126 at n=1000: slow, but guaranteed. Compare 15.1: interpolating at equally spaced points does not converge for every continuous function, which is a reason to value this proof.
Used inside maths· Inside maths: the probabilistic method (a cut that cuts at least half the edges)
To show something exists, show it has positive probability. A graph with m edges: split its vertices into two groups by tossing a fair coin for each vertex. An edge is cut when its endpoints land in different groups, which has chance 21. Let C be the number of cut edges; it is the sum of m indicators, each with mean 21, so E[C]=m/2 by linearity (no independence needed). A random variable cannot be always below its mean, so some split has C≥m/2. Check on K4 (four vertices, all six edges): the average cut over the 16 splits is 3=6/2, and the best split puts two vertices on each side and cuts 4 edges. The proof gives a guarantee without constructing the split.
Used in the real world· Monte Carlo: estimating π, an integral, or a price by random sampling
Throw n random points into the unit square. A point (x,y) is a hit if x2+y2<1, and the chance of a hit is the area of the quarter disc, π/4. So π^=4×(hits)/n. Each throw is Bernoulli(π/4), so Var(π^)=16⋅4π(1−4π)/n≈2.697/n and the standard deviation is about 1.642/n. At n=106 the typical error is 0.0016: three correct digits. The error shrinks like 1/n whatever the problem, so each extra digit costs a hundred times more samples. Chebyshev gives a guarantee: P(∣π^−π∣≥0.01)≤2.697/(n⋅10−4), below 0.05 once n≥540000.
The same idea estimates any integral, as an expectation: ∫01g(x)dx=E[g(U)] for U uniform. With g(x)=4/(1+x2) the integral is π, and g(U) has variance 2π+4−π2≈0.414, about 6.5 times smaller than the hit-or-miss variance. Same answer, a sixth of the samples. Physicists at Los Alamos built the method in the 1940s: Stanisław Ulam, thinking in 1946 about the chance of winning a game of solitaire, saw that one could estimate it by playing many random games, and John von Neumann and others turned the idea to neutron diffusion. Today it prices financial options, renders film frames (path tracing averages random light paths per pixel, which is why images look grainy until enough samples accumulate), and, as Markov chain Monte Carlo (2.11), samples from Bayesian posteriors.
Python labMonte Carlo estimate of π: the error really falls like 1/√n
import numpy as npimport matplotlib.pyplot as pltrng = np.random.default_rng(3)print("n typical error (sd over 200 runs) 1.642/sqrt(n)")for n in (100, 1_000, 10_000): est = 4 * (rng.random((200, n))**2 + rng.random((200, n))**2 < 1).mean(axis=1) print(f"{n:<8d} {est.std():<34.5f} {1.642 / np.sqrt(n):.5f}")x, y = rng.random(2000), rng.random(2000)inside = x**2 + y**2 < 1plt.figure(figsize=(4, 4))plt.scatter(x[inside], y[inside], s=3, color="tab:green")plt.scatter(x[~inside], y[~inside], s=3, color="tab:red")plt.title(f"2000 points: pi is about {4 * inside.mean():.3f}"); plt.gca().set_aspect("equal")
Try this.Check the last column: the typical error (standard deviation over 200 runs) matches 1.642/√n at each n, and going from n = 100 to n = 10000 (100 times more points) makes the error about 10 times smaller, from about 0.166 to 0.0166. Then replace the hit-or-miss line by est = (4 / (1 + rng.random((200, n))**2)).mean(axis=1) and see the error drop by a factor of roughly 2.5 (the square root of 6.5; with only 200 runs the measured ratio wobbles between about 2.5 and 3).
Used in the real world· A Bayesian spam filter: Bayes' theorem on words
In 1998 a Microsoft Research team (Sahami, Dumais, Heckerman and Horvitz) published a Bayesian approach to filtering junk email, and in August 2002 Paul Graham’s essay A Plan for Spam popularised the simple version that most filters copy. Graham reported that his filter, on his own mail, missed fewer than 5 spams in 1000 with no false positives. The idea is Bayes’ theorem with an independence assumption. Let S be “the message is spam”. For each word w in the message, estimate P(w∣S) and P(w∣ham) from counts. The words are treated as conditionally independent given the class: among spam messages, whether ‘free’ appears tells you nothing about whether ‘winner’ appears, and the same among ham. In symbols, P(w1∩w2∣S)=P(w1∣S)P(w2∣S), which is the product rule of independence applied to the conditional measure P(⋅∣S) (a probability measure by the theorem above). This is a weaker claim than plain independence, and it is not the same: ‘free’ and ‘winner’ both occur more often in spam, so over all messages they are dependent. The assumption is called “naive”, is usually false in detail and usually good enough. With it the odds multiply:
Worked example the corpus counts are invented for illustration
A toy corpus of 100 messages: 40 spam, 60 ham. The word 'free' appears in 24 spam and 3 ham messages, 'winner' in 12 spam and 0 ham, 'meeting' in 2 spam and 27 ham. A new message contains 'free' and 'winner'. Find the chance it is spam.
Solution.
Smooth the counts. Estimate P(w∣S)=40+2spam count+1 and P(w∣ham)=60+2ham count+1. Adding 1 stops a word seen in no ham message (like ‘winner’) from getting probability 0, which would make the odds infinite on a single word.
Likelihood ratios. ‘free’: 4/6225/42≈9.23. ‘winner’: 1/6213/42≈19.19. How many times more likely the word is in spam than in ham.
Prior odds.P(S)/P(ham)=40/60=32. The base rate of spam in the corpus.
Multiply. Posterior odds =32×9.23×19.19≈118.0. Bayes’ theorem in odds form with the independence assumption.
Convert to a probability.118.0/(1+118.0)≈0.992. odds =p/(1−p), so p=odds/(1+odds).
Add a harmless word. With ‘meeting’ too, its ratio is 28/623/42≈0.158, so odds ≈18.7 and P(S)≈0.949. A word common in ham pulls the odds down, but two spam words still win.
Answer. About 99.2% spam, and 94.9% if the message also mentions a meeting. Real filters do the same sum over thousands of words, usually with logarithms, so that products become sums and thousands of small factors cannot underflow to zero.
Used in the real world· A/B testing: is version B really better?
A website shows page A to 4000 visitors and page B to another 4000. A gets 200 sign-ups (5.0%) and B gets 240 (6.0%). Is B better, or is this luck? Treat each visitor as a Bernoulli trial. If A and B were equally good, with a common rate near the pooled p^=440/8000=0.055, the difference of the two observed rates has mean 0 and variance p^(1−p^)(40001+40001)≈2.6×10−5, a standard deviation of 0.0051. The observed difference 0.010 is 0.010/0.0051≈1.96 standard deviations. By the normal approximation (the central limit theorem, label B), a gap this large happens by luck about 5% of the time: borderline.
Chebyshev alone gives P(∣diff∣≥0.01)≤2.6×10−5/10−4=0.26, too weak to conclude anything. That is the practical meaning of “Chebyshev is loose”. To design a test that could detect a gap of δ=0.01 around a rate of 5% with the usual 80% power and 5% false-alarm rate, a standard rule of thumb is n≈16p(1−p)/δ2, which gives 16(0.0475)/10−4=7600 visitors per page with p=5% and about 8300 with p=5.5%; the exact normal calculation for 5% against 6% gives about 8150. Choose n before looking at the data: checking repeatedly and stopping the moment the result looks significant inflates the false-alarm rate far above 5%.
Traps
Watch out· P(A given B) is not P(B given A)
A test that catches 99% of sick people does not mean 99% of positives are sick (the quiz above gave about 9%). The two conditional probabilities differ by the ratio of the base rates, which is exactly what Bayes’ theorem multiplies in.
Watch out· Disjoint is not independent
Disjoint events with positive probability are dependent: if one happens the other cannot. Independence needs P(A∩B)=P(A)P(B), not P(A∩B)=0.
Watch out· Pairwise independent is not mutually independent
Three events can be independent two at a time and still fail the product rule for all three (two coins and ‘they agree’). Mutual independence needs the product rule for every sub-collection.
Watch out· A density is not a probability
f(x) can be larger than 1, and P(X=x)=0 for every single x. The probability is the area ∫abf. A probability of 0 does not mean impossible: a uniform point on [0,1] lands somewhere, yet each particular value had chance 0.
Watch out· The law of large numbers does not say the coin is 'due'
After a run of tails, the next toss still has chance 21 of heads. The average settles because the early excess is diluted by a growing number of new tosses, not because the future compensates. The deviation of the count of heads from n/2 typically grows like n; only its ratio to n shrinks.
Watch out· Chebyshev is a guarantee, not an estimate
The bound σ2/c2 holds for every distribution and is therefore far from the truth for any particular one (0.25 against 0.0455 at two standard deviations for a coin average). Use it to prove convergence. To compute a probability, use the distribution or the central limit theorem.
Watch out· Expectation can fail to exist, and the average of the outcomes need not be an outcome
E[X] requires ∫∣x∣f<∞ (or the discrete analogue). The Cauchy distribution has none. And E[die]=3.5 is a value the die never shows.
Problems
check
Events A and B have P(A)=0.3, P(B)=0.2 and P(A∩B)=0.1. Find the probability that at least one of them happens, the probability that neither does, and the probability that exactly one does.
Solution
At least one: P(A∪B)=0.3+0.2−0.1=0.4 (inclusion-exclusion). Neither: the complement, 1−0.4=0.6. Exactly one: the event ”A or B but not both” is (A∪B)∖(A∩B), and A∩B⊆A∪B, so its probability is 0.4−0.1=0.3 (rule 4 of the basic rules).
check
A fair die is rolled twice. Given that the second roll is larger than the first, what is the probability that the first roll was 1?
Solution
The pairs (first, second) with second larger: there are 5+4+3+2+1=15 of them, all equally likely out of 36. Those with first roll 1: (1,2),…,(1,6), five of them. So the probability is 155=31. Equivalently P(second larger)P(first is 1 and second larger)=15/365/36=31.
check
Show that f(x)=4x3 on [0,1] (and 0 elsewhere) is a density. For X with this density find F and P(X<21).
Solution
f≥0 and ∫014x3dx=[x4]01=1. For 0≤x≤1, F(x)=∫0x4t3dt=x4 (with F=0 below 0 and F=1 above 1). So P(X<21)=F(21)=161 (a single point has probability 0, so < and ≤ agree).
check
A variable has mean 50 and standard deviation 5. What does Chebyshev’s inequality say about P(∣X−50∣≥15)?
Solution
P(∣X−50∣≥15)≤15225=22525=91. Here 15=3σ, so this is the case k=3, 1/k2=1/9.
use
In a class of 60 students, 35 know Python, 28 know Java and 12 know both. How many know neither? If a student is chosen at random, what is the probability of knowing neither?
Solution
Inclusion-exclusion: the number who know at least one is 35+28−12=51. So 60−51=9 know neither, and the probability is 9/60=203. (Equal probabilities for all students make P(A)=∣A∣/60 a probability measure, and inclusion-exclusion for probabilities is the counting formula divided by 60.)
use
Urn 1 holds 3 red and 1 blue ball; urn 2 holds 1 red and 3 blue. A fair coin picks an urn, and a ball is drawn (and put back). It is red. What is the probability the urn is urn 1? The ball is drawn again and is red again: now what is the probability?
Solution
Let U1 be “urn 1”. P(red)=21⋅43+21⋅41=21. By Bayes, P(U1∣R)=2121⋅43=43. For two reds in a row (draws with replacement are independent given the urn): P(RR∣U1)=169, P(RR∣U2)=161, so P(U1∣RR)=21⋅169+21⋅16121⋅169=109.
use
Calls reach a help line with an exponential waiting time between calls, mean 4 minutes. What is the chance the next call comes within 2 minutes? What is the median wait: the time m with P(X≤m)=21?
Solution
The rate is λ=41 per minute, so F(x)=1−e−x/4 for x≥0. Within 2 minutes: F(2)=1−e−0.5≈0.3935. For the median we solve 1−e−m/4=21, so e−m/4=21 and m=4ln2≈2.77 minutes. The median is below the mean (4): a few long waits pull the mean up.
use
X is the number shown by a fair die. Find Var(2X+5) and E[(X−3.5)2].
Solution
Var(X)=1235 (worked example). By scaling, Var(2X+5)=4⋅1235=335≈11.67: the shift by 5 changes nothing. And E[(X−3.5)2] is by definition Var(X)=1235≈2.917.
prove
Prove Bonferroni’s inequality: P(A∩B)≥P(A)+P(B)−1, and more generally P(A1∩⋯∩An)≥1−∑i=1nP(Aic).
Solution
By De Morgan, (A1∩⋯∩An)c=A1c∪⋯∪Anc. By the union bound, P(A1c∪⋯∪Anc)≤∑P(Aic). By the complement rule, P(A1∩⋯∩An)=1−P(A1c∪⋯∪Anc)≥1−∑P(Aic). For n=2 the right side is 1−(1−P(A))−(1−P(B))=P(A)+P(B)−1. ■
prove
Prove that an event A with P(A)=0 or P(A)=1 is independent of every event B.
Solution
If P(A)=0: A∩B⊆A, so 0≤P(A∩B)≤P(A)=0, and P(A∩B)=0=P(A)P(B). If P(A)=1: P(Ac)=0, so by the first case Ac is independent of B, and by the theorem on complements, so is A=(Ac)c. Directly: P(A∩B)=P(B)−P(Ac∩B)=P(B)−0=P(B)=P(A)P(B). ■
prove
Prove that if Var(X)=0 then P(X=μ)=1, where μ=E[X].
Solution
For each n, Chebyshev with c=1/n gives P(∣X−μ∣≥n1)≤0⋅n2=0. The events En={∣X−μ∣≥n1} grow with n and their union is {X=μ} (if X(ω)=μ then ∣X(ω)−μ∣≥n1 for large n). By continuity from below, P(X=μ)=limP(En)=0, so P(X=μ)=1. ■
prove
Let A1,A2,… be events. Prove that if P(An)=0 for all n then P(⋃An)=0, and if P(An)=1 for all n then P(⋂An)=1. Why does this fail for uncountable unions?
Solution
By the union bound, 0≤P(⋃An)≤∑P(An)=0. For the second part, the complements have probability 0, so P(⋃Anc)=0, and ⋂An=(⋃Anc)c has probability 1. For uncountable unions: [0,1]=⋃x∈[0,1]{x} is a union of sets of probability 0 under the uniform distribution, but has probability 1. Countable additivity only covers countable lists, which is why 0.3 matters here. ■
stretch
Show that Chebyshev’s inequality cannot be improved without more information: for every c>0 and 0<p≤1, find a random variable X with mean 0 and P(∣X∣≥c)=σ2/c2 exactly.
Solution
Let X=c with probability p/2, X=−c with probability p/2, and X=0 with probability 1−p. Then E[X]=0, E[X2]=c2p, so σ2=c2p. And P(∣X∣≥c)=p=σ2/c2. So equality holds; no smaller bound that depends only on σ2 and c could be true for all distributions.
stretchthe first Borel–Cantelli lemma
Let A1,A2,… be events with ∑nP(An)<∞. Let E be the event that infinitely many of the An happen. Prove that P(E)=0.
Solution
E=⋂N≥1⋃n≥NAn: an outcome is in infinitely many An exactly when for every N it lies in some An with n≥N. For each N, E⊆⋃n≥NAn, so by monotonicity and the union bound P(E)≤∑n≥NP(An). This is the tail of a convergent series, so it tends to 0 as N→∞. Hence P(E)≤0, and P(E)=0. ■ Example: if P(An)=1/n2 then with probability 1 only finitely many of the An occur.
Summary
A probability is a measure of total size 1: never negative, and additive over non-overlapping pieces. The sets it measures (events) form a sigma-algebra, because finite additivity alone does not give limits (the finite/cofinite example) and because not every subset can be measured (Vitali, label B).
Kolmogorov’s axioms are P(A)≥0, P(Ω)=1 and countable additivity. From them we proved P(∅)=0, the complement rule, monotonicity, inclusion-exclusion for 2 and 3 events, the union bound, and continuity from below and above.
Conditional probabilityP(A∣B)=P(A∩B)/P(B) is itself a probability measure. It gives the multiplication rule, the law of total probability and Bayes’ theorem. Independence means P(A∩B)=P(A)P(B); disjoint is not independent, and pairwise is not mutual.
A random variable is a function on the sample space. Its distribution functionF(x)=P(X≤x) is non-decreasing, right-continuous, has limits 0 and 1, and jumps by P(X=a) at a.
A discrete variable has a mass function p with sum 1. A continuous variable has a densityf≥0 with area 1, and probability is area. The uniform, exponential (memoryless, mean 1/λ) and normal (area 1 by the Gaussian integral) densities are the standard examples.
Expectation is the weighted average (absolute convergence required) and is linear. Variance is E[X2]−(E[X])2, scales as a2, and adds for independent variables.
Chebyshev’s inequalityP(∣X−μ∣≥c)≤σ2/c2 follows from Markov’s inequality applied to (X−μ)2. It gives the weak law of large numbers: P(∣Xˉn−μ∣≥ε)≤σ2/(nε2)→0.
Used: Monte Carlo (error ∝1/n), Bayesian spam filters (odds multiply), A/B tests (the normal approximation is needed because Chebyshev is too loose), and, inside maths, Bernstein’s proof of Weierstrass’s theorem.
Watch and read
The same ideas explained by someone else. Use these when an explanation here does not land.
MATH 431: 431 starts from the triple (Ω, F, P) and countable additivity (Lecture 1), proves complement, monotonicity and inclusion-exclusion, then conditional probability and Bayes (Lectures 5 and 6), independence (Lecture 7), the binomial and geometric distributions (Lecture 8), cdfs and densities (Lecture 10), expectation (Lecture 11) and variance (Lecture 12). This chapter proves the same rules from the same axioms, and goes on to Chebyshev's inequality and the law of large numbers, which come later in the 431 textbook.
MATH 521 / measure theory: A sigma-algebra and a countably additive measure are the two definitions that a first course on Lebesgue measure starts with. The only new work there is building a measure on the real line that is defined on enough sets, which is the construction this chapter only points at.
CS 532 / AI: Bayes' theorem is how a classifier turns likelihoods into a posterior, and Monte Carlo estimation (sample, average, trust the law of large numbers) is behind dropout, stochastic gradient descent and sampling from a language model. The error shrinking like one over the square root of n is proved here.
CS 240: A random variable is a function from outcomes to numbers, and the expected running time of a randomized algorithm is an expectation. Linearity of expectation, proved below for countable sample spaces, is the standard tool.