Raw

Lecture 13. Probabilities

13.1 Overview

Every branch of mathematics we have met so far describes a deterministic world: a set either contains an element or it does not (Lectures 1–2), two elements are either related or they are not (Lecture 3), a proposition is either true or false (Lecture 6). Probability theory is the branch of discrete mathematics that extends this black-and-white logic to a world of graded certainty — it attaches to each uncertain statement a number between 00 and 11 measuring how likely it is to be true.

Why should a computer scientist care? Because the most powerful ideas in modern computing are probabilistic:

  • Randomized algorithms (quicksort with a random pivot, randomized primality testing, skip lists, hashing) trade a tiny chance of a bad outcome for dramatic speed. Analysing them means computing P(algorithm is slow)P(\text{algorithm is slow}) and showing it is negligible.
  • Hashing and load balancing live or die by collision probabilities — the birthday problem of this lecture is exactly the analysis of a hash table.
  • Machine learning is applied probability: a spam filter computes P(spamwords)P(\text{spam}\mid\text{words}) with Bayes’ theorem; a classifier’s precision and recall are conditional probabilities.
  • Cryptography rests on the infeasibility of guessing a random key, and the “birthday attack” is a direct application of the birthday problem.
  • Networks, queues, and reliability are modelled by the probability that a packet is lost, a server is busy, or a component fails.

This lecture builds finite (discrete) probability from the ground up in three stages.

  1. Language. Random experiments, the sample space Ω\Omega, and events — which turn out to be nothing more than the sets of Lecture 1, so the whole algebra of Lecture 2 transfers verbatim.
  2. Measure. How to attach a number P(A)[0,1]P(A)\in[0,1] to an event: the classical (Laplace) ratio, the counting tools (combinatorics) needed to evaluate it, and the three axioms of Kolmogorov that pin down what “probability” is.
  3. A calculus of events. Theorems that combine probabilities — the complement rule, the addition rule (a probabilistic inclusion–exclusion), conditional probability, the multiplication rule, independence, the law of total probability, and Bayes’ theorem — each stated precisely and proved from the axioms.

We close with three celebrated problems every student should meet once — the birthday problem, the Monty Hall problem, and a Bayesian medical-test calculation — and a first look at random variables and expectation.

Throughout we stay in the discrete, finite world: the sample space has finitely many outcomes. Continuous distributions (the normal curve, densities, integrals) are the subject of a later course and are out of scope here.

13.2 Random experiments, sample space, and events

A random experiment (trial) is a process whose individual outcome cannot be predicted with certainty in advance, even though the set of possible outcomes is known and the experiment can (in principle) be repeated under identical conditions. Tossing a coin, rolling a die, drawing a card, and picking a ball from an urn are the classic examples; so is “hash a random key into a table of size mm” or “run randomized quicksort on this array.”

The sample space Ω\Omega (also written SS or UU) is the set of all possible outcomes of the experiment. Each individual outcome ωΩ\omega\in\Omega is an elementary event (sample point) — an outcome that cannot be decomposed further.

An event is any statement about the experiment that becomes definitely true or false once the outcome is known — formally, a subset AΩA\subseteq\Omega. The event occurs exactly when the realized outcome ω\omega belongs to AA. An event containing more than one elementary outcome is a compound event.

Example (die). Roll one fair six-sided die, so Ω={1,2,3,4,5,6}\Omega=\{1,2,3,4,5,6\} and Ω=6|\Omega|=6. The elementary event “roll a 44” is the singleton {4}\{4\}. The compound event A=A= “even number” is {2,4,6}\{2,4,6\}; B=B= “greater than 44” is {5,6}\{5,6\}. Then AB={2,4,5,6}A\cup B=\{2,4,5,6\}, AB={6}A\cap B=\{6\}, and A={1,3,5}\overline{A}=\{1,3,5\}.

Example (two coins). Toss two distinguishable coins: Ω={HH,HT,TH,TT}\Omega=\{HH,HT,TH,TT\}, Ω=4|\Omega|=4. The event “exactly one head” is {HT,TH}\{HT,TH\}. Note that this Ω\Omega is the Cartesian product {H,T}×{H,T}\{H,T\}\times\{H,T\} from Lecture 2 — building compound sample spaces out of simple ones is exactly the product construction.

Probability tree for tossing two coins, enumerating the sample space Ω = {HH, HT, TH, TT} with |Ω| = 4

Events are sets: the algebra of events

Because an event is a subset of Ω\Omega, the set operations of Lectures 1–2 carry over with no change — only the reading changes. This dictionary is the single most useful table in the lecture; keep it in view.

Set notation Event language “occurs when…”
ωA\omega\in A outcome ω\omega makes AA occur the realized outcome lies in AA
Ω\Omega certain event always
\varnothing impossible event never
ABA\cup B AA or BB” (at least one) ωA\omega\in A or ωB\omega\in B
ABA\cap B (also ABAB) AA and BB” (both) ωA\omega\in A and ωB\omega\in B
A=ΩA\overline{A}=\Omega\setminus A not AA ωA\omega\notin A
ABA\subseteq B AA implies BB whenever AA occurs, so does BB
AB=A\cap B=\varnothing A,BA,B mutually exclusive they cannot co-occur
AB=ABA\setminus B=A\cap\overline B AA but not BB ωA\omega\in A and ωB\omega\notin B

Consequently De Morgan’s laws from Lecture 2 read, in event language,

AB=AB("not (A or B)"="neither"),AB=AB.\overline{A\cup B}=\overline A\cap\overline B\quad(\text{"not (}A\text{ or }B\text{)}"=\text{"neither"}),\qquad \overline{A\cap B}=\overline A\cup\overline B .

Remark (why “events as sets” matters). This is not a coincidence to be admired and forgotten. Every probability manipulation below is first a set manipulation and then an application of an axiom. When a word problem confuses you, translate it into set operations on Ω\Omega first; the arithmetic follows.

Remark (the event space). For a finite Ω\Omega we take every subset to be an event, so the collection of events is the power set 2Ω2^{\Omega} (Lecture 1), with 2Ω=2Ω|2^{\Omega}|=2^{|\Omega|} events in all. For infinite sample spaces one cannot always take every subset and must restrict to a so-called σ\sigma-algebra; that subtlety never arises in the finite world of this lecture.

13.3 Types of events

Classifying how events relate to one another decides which rule applies later, so the vocabulary is worth stating precisely.

Certain (reliable) event — occurs in every trial. It is the whole sample space Ω\Omega and (we will prove) has probability 11. Example: “the die shows a number in {1,,6}\{1,\dots,6\}.”

Impossible eventnever occurs. It is the empty set \varnothing and has probability 00. Example: “the die shows 77.”

Compatible (jointly possible) eventscan occur in the same trial: ABA\cap B\neq\varnothing. On one die, A=A= “even” and B=B= “greater than 33” share the outcome 66, so they are compatible.

Incompatible (mutually exclusive) eventscannot occur together: AB=A\cap B=\varnothing (the disjoint sets of Lecture 2). “Roll a 22” and “roll a 55” cannot both happen in one roll. Distinct elementary events are always pairwise incompatible.

A family of events A1,,AnA_1,\dots,A_n forms a complete group (a partition of Ω\Omega) if they are pairwise incompatible and their union is Ω\Omega — so exactly one of them occurs in every trial. This is precisely the partition concept of Lecture 3, where a partition of a set arose as the family of equivalence classes of an equivalence relation. There, blocks were “elements that are equivalent”; here, blocks are “outcomes that trigger the same hypothesis.” The idea returns as the backbone of the total-probability formula.

Complementary (opposite) events — the special case of a complete group of two: AA and A\overline{A} are incompatible and together exhaust Ω\Omega. Example: “the die shows 66” and “the die does not show 66.” We will prove P(A)+P(A)=1P(A)+P(\overline A)=1.

Independent events — the occurrence of one does not change the probability of the other (made precise below). Drawing a ball, replacing it, then drawing again gives independent draws.

Dependent events — the occurrence of one does change the probability of the other. Drawing two balls without replacement makes the second draw depend on the first.

Common pitfall. Independence is not the same as incompatibility — in fact they are almost opposites. We will prove that two incompatible events of positive probability are necessarily dependent: if AA occurs then BB has become impossible, which is a maximal change in BB’s probability. Do not equate “AB=A\cap B=\varnothing” with “A,BA,B independent.”

13.4 The classical (Laplace) definition of probability

When a finite experiment has nn equally likely elementary outcomes, of which exactly mm are favourable to an event AA, the classical (Laplace) probability of AA is

P(A)=mn=AΩ=number of favourable outcomesnumber of possible outcomes.P(A)=\frac{m}{n}=\frac{\lvert A\rvert}{\lvert\Omega\rvert}=\frac{\text{number of favourable outcomes}}{\text{number of possible outcomes}}.

The “equally likely” hypothesis is essential and is justified by symmetry: a fair coin, a fair die, a well-shuffled deck, and a thoroughly mixed urn have no physical reason to prefer one outcome over another. Where symmetry fails, the classical definition does not apply and we fall back on the statistical definition below.

Example (die). P(even)=36=12P(\text{even})=\tfrac{3}{6}=\tfrac12, since 33 of the 66 equally likely faces are even.

Example (cards). From a standard 5252-card deck, P(ace)=452=113P(\text{ace})=\tfrac{4}{52}=\tfrac1{13} and P(face card)=1252=313P(\text{face card})=\tfrac{12}{52}=\tfrac3{13} (the 1212 jacks, queens, kings).

Because 0mn0\le m\le n, the ratio always lies in [0,1][0,1]; P(Ω)=n/n=1P(\Omega)=n/n=1 and P()=0/n=0P(\varnothing)=0/n=0. The whole of classical probability therefore reduces to a counting problem — “how many favourable, how many total?” — which is why we develop combinatorics next.

Statistical (frequentist) probability. When symmetry fails (a bent coin, an unknown manufacturing process) we estimate probability empirically. If in NN independent trials the event AA occurs NAN_A times, its relative frequency is W(A)=NA/NW(A)=N_A/N. The law of large numbers says that as NN\to\infty this frequency stabilizes around a fixed number, the statistical probability P(A)P(A). For fair mechanisms the statistical and classical values agree; the statistical view is what lets us speak of “the probability of rain” or “the probability a hard drive fails within a year,” where no symmetry is available.

13.5 Counting: combinatorics as the engine of classical probability

To use P(A)=m/nP(A)=m/n we must count outcomes. Three counting devices — resting on one master principle — handle almost every finite problem. Throughout, nn is the number of available objects and kk the number chosen.

The multiplication principle (rule of product)

Multiplication principle. If a procedure consists of kk successive steps, where step 11 can be done in n1n_1 ways, step 22 in n2n_2 ways regardless of the first choice, …, and step kk in nkn_k ways regardless of the earlier choices, then the whole procedure can be carried out in

n1n2nkways.n_1\cdot n_2\cdots n_k\quad\text{ways.}

Proof. An outcome of the procedure is precisely a kk-tuple (x1,,xk)(x_1,\dots,x_k) with xix_i one of the nin_i choices at step ii, so the set of outcomes is the Cartesian product X1××XkX_1\times\cdots\times X_k of Lecture 2 with Xi=ni|X_i|=n_i. The cardinality of a finite Cartesian product is the product of the cardinalities, X1××Xk=ini|X_1\times\cdots\times X_k|=\prod_i n_i, which one proves by induction on kk: the case k=1k=1 is immediate, and X1××Xk=X1××Xk1Xk|X_1\times\cdots\times X_{k}|=|X_1\times\cdots\times X_{k-1}|\cdot|X_k| because each of the X1××Xk1|X_1\times\cdots\times X_{k-1}| shorter tuples extends in exactly nkn_k ways. ∎

Example. A password of 33 lowercase letters followed by 22 digits can be formed in 2626261010=263102=1,757,60026\cdot26\cdot26\cdot10\cdot10=26^3\cdot10^2=1{,}757{,}600 ways. Rolling two dice yields 66=366\cdot6=36 ordered outcomes — the sample space {1,,6}×{1,,6}\{1,\dots,6\}\times\{1,\dots,6\}.

Permutations

Permutation of nn objects — an ordering (in a row) of all nn distinct objects. The number of permutations is

Pn=n!=123n,with the convention 0!=1.P_n=n!=1\cdot2\cdot3\cdots n,\qquad\text{with the convention }0!=1.

Proof. Filling the nn positions left to right is a k=nk=n-step procedure: the first position admits nn choices, the second n1n-1 (one object is used up), …, the last 11. By the multiplication principle the count is n(n1)1=n!n(n-1)\cdots1=n!. ∎

kk-permutation (arrangement) — an ordered selection of kk out of nn distinct objects (order matters, no repetition). Its count, written P(n,k)P(n,k) (the notation used in Rosen; the same quantity appears in the European tradition as AnkA_n^{k}, the number of arrangements), is

P(n,k)=Ank=n!(nk)!=n(n1)(nk+1)k factors.P(n,k)=A_n^{k}=\frac{n!}{(n-k)!}=\underbrace{n(n-1)\cdots(n-k+1)}_{k\text{ factors}}.

Proof. Fill kk ordered positions from nn objects: nn choices for the first, n1n-1 for the second, …, nk+1n-k+1 for the kk-th. The product of these kk factors is n(n1)(nk+1)n(n-1)\cdots(n-k+1), which equals n!/(nk)!n!/(n-k)! after cancelling the tail (nk)(nk1)1(n-k)(n-k-1)\cdots1. ∎

Example. Choosing a president and then a (distinct) secretary from 1010 people gives P(10,2)=109=90P(10,2)=10\cdot9=90 ordered pairs. All orderings of 55 books on a shelf: P5=5!=120P_5=5!=120.

Combinations

Combination — an unordered selection of kk out of nn distinct objects (order does not matter, no repetition), i.e. a kk-element subset. Its count is the binomial coefficient

(nk)=C(n,k)=Cnk=n!k!(nk)!,0kn.\binom{n}{k}=C(n,k)=C_n^{k}=\frac{n!}{k!\,(n-k)!},\qquad 0\le k\le n.

Proof. Count ordered kk-selections two ways. On one hand there are P(n,k)=n!/(nk)!P(n,k)=n!/(n-k)! of them. On the other hand, to build an ordered selection we may first choose the set of kk objects — say there are (nk)\binom{n}{k} such sets — and then order them, which by the permutation count can be done in k!k! ways. By the multiplication principle P(n,k)=(nk)k!P(n,k)=\binom{n}{k}\cdot k!, so

(nk)=P(n,k)k!=n!k!(nk)!.\binom{n}{k}=\frac{P(n,k)}{k!}=\frac{n!}{k!\,(n-k)!}.\qquad\blacksquare

Example. A committee of 33 from 1010 people: (103)=10!3!7!=1098321=120\binom{10}{3}=\dfrac{10!}{3!\,7!}=\dfrac{10\cdot9\cdot8}{3\cdot2\cdot1}=120. (Contrast with the ordered count P(10,3)=720P(10,3)=720; dividing by 3!=63!=6 removes the ordering.)

Two facts we will reuse:

  • Symmetry: (nk)=(nnk)\binom{n}{k}=\binom{n}{n-k}, since choosing the kk objects to include is the same as choosing the nkn-k objects to exclude.
  • Pascal’s identity: (nk)=(n1k1)+(n1k)\displaystyle\binom{n}{k}=\binom{n-1}{k-1}+\binom{n-1}{k}.

Proof of Pascal’s identity (combinatorial). Fix one particular object xx among the nn. Every kk-subset either contains xx or not. Those containing xx are formed by choosing the remaining k1k-1 members from the other n1n-1 objects: (n1k1)\binom{n-1}{k-1} of them. Those not containing xx choose all kk members from the other n1n-1: (n1k)\binom{n-1}{k} of them. These two cases are disjoint and exhaustive, so their counts add. ∎

Common pitfall (a notation clash). The letter PP is overloaded: P(A)P(A) is the probability of an event AA, while P(n,k)P(n,k) is the number of kk-permutations. They are told apart only by what sits inside the parentheses (a set/event vs. two integers). To avoid confusion this lecture writes probabilities of named events, e.g. P(A)P(A), and permutation counts with two integer arguments, e.g. P(10,2)=90P(10,2)=90. The European-tradition notation AnkA_n^k, CnkC_n^k sidesteps the clash entirely.

Order matters? The single question that selects the tool: does rearranging the chosen objects give a different outcome? Yes ⇒ permutation P(n,k)P(n,k); No ⇒ combination (nk)\binom{n}{k}. “President and secretary” is ordered; “a committee” is not.

Table contrasting permutations (order matters) with combinations (order does not); for n=5, k=2 they give 20 versus 10

Example (urn, counting). An urn holds 66 white and 44 black balls; draw 33 at once (order irrelevant). Total selections: (103)=120\binom{10}{3}=120. Favourable to “exactly 22 white and 11 black”: choose the whites (62)=15\binom{6}{2}=15 ways and the black (41)=4\binom{4}{1}=4 ways, giving 154=6015\cdot4=60. Hence

P(2 white, 1 black)=(62)(41)(103)=60120=12.P(\text{2 white, 1 black})=\frac{\binom{6}{2}\binom{4}{1}}{\binom{10}{3}}=\frac{60}{120}=\frac12 .

(This is a hypergeometric count — sampling without replacement — and we return to it below.)

Three more counting tools

  • Sum rule (addition principle). If an object comes from one of disjoint cases with m1,m2,m_1, m_2,\dots options, the total is m1+m2+m_1+m_2+\cdots. “Or / separate cases” adds, where the product rule’s “and / in stages” multiplies.
  • Selections with repetition (multisets / stars-and-bars). Choosing kk objects from nn types with repetition allowed — equivalently, distributing kk identical balls into nn distinct boxes — is counted by

    C(n,k)=(n+k1k)\overline{C}(n,k)=\binom{n+k-1}{k}

    (line up kk stars and n1n-1 bars). This fills the last cell of the order-vs-repetition taxonomy: unordered with repetition.
  • Binomial theorem. The combinations are the coefficients of a binomial power:

    (x+y)n=k=0n(nk)xkynk,(x+y)^n=\sum_{k=0}^{n}\binom{n}{k}x^k y^{n-k},

    whence k(nk)=2n\sum_k\binom{n}{k}=2^n (put x=y=1x=y=1) and the binomial-distribution weights (nk)pk(1p)nk\binom{n}{k}p^k(1-p)^{n-k} sum to 11 (put x=p, y=1px=p,\ y=1-p).

13.6 Kolmogorov’s axioms

The classical ratio m/nm/n works only for equally likely outcomes and only for finite spaces. In 1933 A. N. Kolmogorov gave probability the abstract, symmetry-free foundation still used today: probability is any function on events obeying three axioms.

Definition (probability measure). A probability on a finite sample space Ω\Omega is a function PP assigning to every event AΩA\subseteq\Omega a real number P(A)P(A) such that

  1. (Non-negativity) P(A)0P(A)\ge0 for every event AA;
  2. (Normalization) P(Ω)=1P(\Omega)=1;
  3. (Additivity) if AB=A\cap B=\varnothing then P(AB)=P(A)+P(B)P(A\cup B)=P(A)+P(B); more generally, for pairwise incompatible events A1,A2,A_1,A_2,\dots (finitely or countably many),

P ⁣(iAi)=iP(Ai).P\!\Big(\bigcup_i A_i\Big)=\sum_i P(A_i).

Everything else in this lecture is a theorem deduced from these three lines. Nothing about “equally likely” is assumed; the classical model is just one instance.

Building a finite probability space. On a finite Ω={ω1,,ωn}\Omega=\{\omega_1,\dots,\omega_n\} it suffices to assign each outcome a weight pi=P({ωi})0p_i=P(\{\omega_i\})\ge0 with i=1npi=1\sum_{i=1}^n p_i=1, and then define P(A)=ωiApiP(A)=\sum_{\omega_i\in A}p_i. Additivity then holds automatically. The classical (uniform) model is the special case pi=1/np_i=1/n for all ii.

Theorem (the classical ratio is a probability). For finite Ω\Omega with Ω=n|\Omega|=n, the function P(A)=A/nP(A)=|A|/n satisfies the three axioms.

Proof. Non-negativity: A0|A|\ge0, so P(A)0P(A)\ge0. Normalization: P(Ω)=Ω/n=n/n=1P(\Omega)=|\Omega|/n=n/n=1. Additivity: if AB=A\cap B=\varnothing then AB=A+B|A\cup B|=|A|+|B| — this is exactly the disjoint-union counting rule of Lecture 2 — so P(AB)=A+Bn=An+Bn=P(A)+P(B)P(A\cup B)=\dfrac{|A|+|B|}{n}=\dfrac{|A|}{n}+\dfrac{|B|}{n}=P(A)+P(B). ∎

13.7 Derived rules and their proofs

We now prove, purely from Axioms 1–3, the working rules of probability. These proofs are the mathematical heart of the lecture; each is short, and together they show how much structure three axioms already force.

Theorem (finite additivity). If A1,,AnA_1,\dots,A_n are pairwise incompatible then P(A1An)=i=1nP(Ai)P(A_1\cup\cdots\cup A_n)=\sum_{i=1}^n P(A_i).

Proof. Induction on nn. The case n=2n=2 is Axiom 3. Assume the claim for n1n-1 and let A1,,AnA_1,\dots,A_n be pairwise incompatible. Put B=A1An1B=A_1\cup\cdots\cup A_{n-1}. Then BAn=(i<nAi)An=i<n(AiAn)=i<n=B\cap A_n=\big(\bigcup_{i<n}A_i\big)\cap A_n=\bigcup_{i<n}(A_i\cap A_n)=\bigcup_{i<n}\varnothing=\varnothing, so by Axiom 3 and the induction hypothesis

P(inAi)=P(BAn)=P(B)+P(An)=i<nP(Ai)+P(An)=inP(Ai).P\Big(\bigcup_{i\le n}A_i\Big)=P(B\cup A_n)=P(B)+P(A_n)=\sum_{i<n}P(A_i)+P(A_n)=\sum_{i\le n}P(A_i).\qquad\blacksquare

Theorem (impossible event). P()=0P(\varnothing)=0.

Proof. =\varnothing\cap\varnothing=\varnothing and =\varnothing\cup\varnothing=\varnothing, so \varnothing is incompatible with itself. Axiom 3 gives P()=P()=P()+P()=2P()P(\varnothing)=P(\varnothing\cup\varnothing)=P(\varnothing)+P(\varnothing)=2\,P(\varnothing). Subtracting P()P(\varnothing) from both sides yields P()=0P(\varnothing)=0. ∎

Theorem (complement rule). For every event AA,   P(A)=1P(A)\;P(\overline A)=1-P(A).

Proof. AA and A\overline A are incompatible (AA=A\cap\overline A=\varnothing) and exhaust the space (AA=ΩA\cup\overline A=\Omega). By Axiom 3 and then Axiom 2,

P(A)+P(A)=P(AA)=P(Ω)=1,P(A)+P(\overline A)=P(A\cup\overline A)=P(\Omega)=1,

so P(A)=1P(A)P(\overline A)=1-P(A). ∎

This is the workhorse behind every “at least one” computation, because the complement “none” is usually far easier to count.

Theorem (range of probability). For every event AA,   0P(A)1\;0\le P(A)\le1.

Proof. The lower bound is Axiom 1. For the upper bound, the complement rule gives P(A)=1P(A)P(A)=1-P(\overline A), and P(A)0P(\overline A)\ge0 by Axiom 1, so P(A)1P(A)\le1. ∎

Theorem (monotonicity and difference). If ABA\subseteq B then P(BA)=P(B)P(A)P(B\setminus A)=P(B)-P(A) and hence P(A)P(B)P(A)\le P(B).

Proof. Since ABA\subseteq B, the set BB splits as the disjoint union B=A(BA)B=A\cup(B\setminus A) with A(BA)=A\cap(B\setminus A)=\varnothing. Axiom 3 gives P(B)=P(A)+P(BA)P(B)=P(A)+P(B\setminus A), whence P(BA)=P(B)P(A)P(B\setminus A)=P(B)-P(A). As P(BA)0P(B\setminus A)\ge0 by Axiom 1, we get P(A)P(B)P(A)\le P(B). ∎

Theorem (addition rule / inclusion–exclusion for two events). For any two events,

P(AB)=P(A)+P(B)P(AB).P(A\cup B)=P(A)+P(B)-P(A\cap B).

Proof. Write ABA\cup B as the disjoint union AB=A(BA)A\cup B=A\cup(B\setminus A), so by Axiom 3

P(AB)=P(A)+P(BA).(1)P(A\cup B)=P(A)+P(B\setminus A).\tag{1}

Now ABBA\cap B\subseteq B, and BB splits as the disjoint union B=(AB)(BA)B=(A\cap B)\cup(B\setminus A) (an outcome of BB is either also in AA or not), so by Axiom 3

P(B)=P(AB)+P(BA)  P(BA)=P(B)P(AB).(2)P(B)=P(A\cap B)+P(B\setminus A)\ \Longrightarrow\ P(B\setminus A)=P(B)-P(A\cap B).\tag{2}

Substituting (2) into (1) gives P(AB)=P(A)+P(B)P(AB)P(A\cup B)=P(A)+P(B)-P(A\cap B). ∎

Remark. This is the probabilistic twin of the cardinality identity AB=A+BAB|A\cup B|=|A|+|B|-|A\cap B| proved in Lecture 2; dividing that by Ω|\Omega| in the classical model recovers it. The overlap ABA\cap B is subtracted because outcomes in it are counted once in P(A)P(A) and again in P(B)P(B). For incompatible events AB=A\cap B=\varnothing, the term vanishes and we recover P(AB)=P(A)+P(B)P(A\cup B)=P(A)+P(B).

Theorem (inclusion–exclusion for three events).

P(ABC)=P(A)+P(B)+P(C)P(AB)P(AC)P(BC)+P(ABC).P(A\cup B\cup C)=P(A)+P(B)+P(C)-P(A\cap B)-P(A\cap C)-P(B\cap C)+P(A\cap B\cap C).

Proof. Apply the two-event rule to (AB)(A\cup B) and CC:

P((AB)C)=P(AB)+P(C)P((AB)C).P\big((A\cup B)\cup C\big)=P(A\cup B)+P(C)-P\big((A\cup B)\cap C\big).

Expand P(AB)=P(A)+P(B)P(AB)P(A\cup B)=P(A)+P(B)-P(A\cap B). For the last term, distributivity (Lecture 2) gives (AB)C=(AC)(BC)(A\cup B)\cap C=(A\cap C)\cup(B\cap C), so by the two-event rule again

P((AB)C)=P(AC)+P(BC)P((AC)(BC)),P\big((A\cup B)\cap C\big)=P(A\cap C)+P(B\cap C)-P\big((A\cap C)\cap(B\cap C)\big),

and (AC)(BC)=ABC(A\cap C)\cap(B\cap C)=A\cap B\cap C. Combining the pieces gives the stated formula. ∎

Theorem (Boole’s inequality / union bound). For any events A1,,AnA_1,\dots,A_n,

P(i=1nAi)i=1nP(Ai).P\Big(\bigcup_{i=1}^n A_i\Big)\le\sum_{i=1}^n P(A_i).

Proof. Induction on nn. For n=1n=1 it is an equality. Assume it for n1n-1. Writing U=i<nAiU=\bigcup_{i<n}A_i, the two-event addition rule gives P(UAn)=P(U)+P(An)P(UAn)P(U)+P(An)P(U\cup A_n)=P(U)+P(A_n)-P(U\cap A_n)\le P(U)+P(A_n), since P(UAn)0P(U\cap A_n)\ge0. By the induction hypothesis P(U)i<nP(Ai)P(U)\le\sum_{i<n}P(A_i), so P(inAi)inP(Ai)P(\bigcup_{i\le n}A_i)\le\sum_{i\le n}P(A_i). ∎

CS connection. The union bound is the single most-used inequality in the analysis of randomized algorithms. If an algorithm fails only when at least one of nn “bad events” AiA_i happens, and each has tiny probability P(Ai)δ/nP(A_i)\le\delta/n, then the total failure probability is at most n(δ/n)=δn\cdot(\delta/n)=\delta — no independence assumptions needed. Its power is that it needs nothing about how the AiA_i interact.

13.8 Worked problems I: dice, cards, urns

We consolidate the rules so far on the three workhorse experiments, easy to hard. Every number is verified.

Problem 1 (single die, warm-up). Roll one fair die. Then P(prime)=P({2,3,5})=36=12P(\text{prime})=P(\{2,3,5\})=\tfrac36=\tfrac12 and, since “roll 11 or 22” are incompatible, P({1}{2})=16+16=13P(\{1\}\cup\{2\})=\tfrac16+\tfrac16=\tfrac13.

Problem 2 (two dice, the sum distribution). Roll two fair dice; Ω=36|\Omega|=36 equally likely ordered pairs. Counting the pairs (a,b)(a,b) with a+b=sa+b=s gives the full distribution:

Sum ss 2 3 4 5 6 7 8 9 10 11 12
favourable pairs 1 2 3 4 5 6 5 4 3 2 1
P(sum=s)P(\text{sum}=s) 136\tfrac1{36} 236\tfrac2{36} 336\tfrac3{36} 436\tfrac4{36} 536\tfrac5{36} 636\tfrac6{36} 536\tfrac5{36} 436\tfrac4{36} 336\tfrac3{36} 236\tfrac2{36} 136\tfrac1{36}

The counts sum to 1+2++6++2+1=361+2+\cdots+6+\cdots+2+1=36, confirming the probabilities total 11. The most likely sum is 77 (six ways: (1,6),(2,5),(3,4),(4,3),(5,2),(6,1)(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)), giving P(sum=7)=636=16P(\text{sum}=7)=\tfrac{6}{36}=\tfrac16.

Problem 3 (at least one six — complement). Roll two dice. P(no six)=(56)2=2536P(\text{no six})=\big(\tfrac56\big)^2=\tfrac{25}{36} (each die independently avoids six), so by the complement rule P(at least one six)=12536=11360.306P(\text{at least one six})=1-\tfrac{25}{36}=\tfrac{11}{36}\approx0.306. Direct enumeration confirms 1111 of the 3636 pairs contain a six.

Problem 4 (cards, addition rule). Draw one card from 5252.

P(king or heart)=P(king)+P(heart)P(king of hearts)=452+1352152=1652=413,P(\text{king or heart})=P(\text{king})+P(\text{heart})-P(\text{king of hearts}) =\tfrac{4}{52}+\tfrac{13}{52}-\tfrac{1}{52}=\tfrac{16}{52}=\tfrac{4}{13},

subtracting the king of hearts, counted in both.

Problem 5 (cards, two aces). Draw 22 cards without replacement. Counting unordered hands, P(both aces)=(42)(522)=61326=12210.0045P(\text{both aces})=\dfrac{\binom{4}{2}}{\binom{52}{2}}=\dfrac{6}{1326}=\dfrac1{221}\approx0.0045. The sequential view agrees: 452351=122652=1221\tfrac{4}{52}\cdot\tfrac{3}{51}=\tfrac{12}{2652}=\tfrac1{221}.

Problem 6 (cards, at least one ace in a 5-card hand — complement).

P(no ace)=(485)(525)=1,712,3042,598,9600.6588,P(at least one ace)10.6588=0.3412.P(\text{no ace})=\frac{\binom{48}{5}}{\binom{52}{5}}=\frac{1{,}712{,}304}{2{,}598{,}960}\approx0.6588, \qquad P(\text{at least one ace})\approx1-0.6588=0.3412.

Problem 7 (urn without replacement, hypergeometric). An urn has 66 white and 44 black balls; draw 33 without replacement.

Event Count Probability
all 33 white (63)=20\binom63=20 20/120=160.16720/120=\tfrac16\approx0.167
exactly 22 white, 11 black (62)(41)=60\binom62\binom41=60 60/120=1260/120=\tfrac12
exactly 11 white, 22 black (61)(42)=36\binom61\binom42=36 36/120=310=0.336/120=\tfrac{3}{10}=0.3
no white (33 black) (43)=4\binom43=4 4/120=1300.0334/120=\tfrac1{30}\approx0.033

The four cases partition the outcomes: 20+60+36+4=120=(103)20+60+36+4=120=\binom{10}{3}, so the probabilities sum to 11. ✓

Problem 8 (De Méré’s problem, historical, hard). The Chevalier de Méré, a 17th-century gambler, asked Pascal about two bets that “should” have equal odds:

  • Bet A: at least one six in four rolls of one die.
  • Bet B: at least one double-six in twenty-four rolls of two dice.

Using the complement rule and independence of rolls,

P(A)=1(56)4=16251296=67112960.5177,P(\text{A})=1-\Big(\tfrac56\Big)^{4}=1-\tfrac{625}{1296}=\tfrac{671}{1296}\approx0.5177,

P(B)=1(3536)2410.5086=0.4914.P(\text{B})=1-\Big(\tfrac{35}{36}\Big)^{24}\approx1-0.5086=0.4914.

So Bet A is (barely) favourable and Bet B (barely) unfavourable — a difference of about 2.62.6 percentage points that de Méré had detected empirically at the gaming table. The correspondence Pascal and Fermat exchanged to resolve such puzzles in 1654 is usually taken as the birth of probability theory.

13.9 Conditional probability

Often we learn partial information — a related event BB is known to have occurred — and must revise the probability of AA accordingly.

Definition (conditional probability). For events A,BA,B with P(B)>0P(B)>0, the conditional probability of AA given BB is

P(AB)=P(AB)P(B).P(A\mid B)=\frac{P(A\cap B)}{P(B)}.

Venn diagram of overlapping events A and B, with the shaded intersection illustrating P(A|B) = P(A∩B)/P(B)

Intuition. Learning that BB occurred shrinks the world from Ω\Omega down to BB: outcomes outside BB are now impossible. We rescale so that BB carries the full probability 11 (divide by P(B)P(B)) and ask what fraction of BB’s probability also lies in AA (the numerator P(AB)P(A\cap B)). In the classical model this is transparent: P(AB)=AB/ΩB/Ω=ABBP(A\mid B)=\dfrac{|A\cap B|/|\Omega|}{|B|/|\Omega|}=\dfrac{|A\cap B|}{|B|} — literally “favourable-within-BB over size-of-BB.”

Example (die). With A=A=“roll a 22” and B=B=“even”: P(AB)=P({2})P({2,4,6})=1/63/6=13P(A\mid B)=\dfrac{P(\{2\})}{P(\{2,4,6\})}=\dfrac{1/6}{3/6}=\dfrac13. Knowing the roll is even lifts the chance of a 22 from 16\tfrac16 to 13\tfrac13, because only three outcomes remain.

Remark (conditioning yields a probability). For fixed BB with P(B)>0P(B)>0, the map AP(AB)A\mapsto P(A\mid B) is itself a probability measure on Ω\Omega: it is non-negative, assigns P(ΩB)=P(B)/P(B)=1P(\Omega\mid B)=P(B)/P(B)=1, and is additive over incompatible events. So every theorem proved above (complement rule, addition rule, …) holds inside a conditional world.

The multiplication rule and the chain rule

Rearranging the definition removes the fraction and gives the probability that both events occur.

Multiplication rule. For P(A),P(B)>0P(A),P(B)>0,

P(AB)=P(B)P(AB)=P(A)P(BA).P(A\cap B)=P(B)\,P(A\mid B)=P(A)\,P(B\mid A).

This generalizes to any number of events.

Theorem (chain rule / general multiplication rule). For events A1,,AnA_1,\dots,A_n with P(A1An1)>0P(A_1\cap\cdots\cap A_{n-1})>0,

P(A1A2An)=P(A1)P(A2A1)P(A3A1A2)P(AnA1An1).P(A_1\cap A_2\cap\cdots\cap A_n)=P(A_1)\,P(A_2\mid A_1)\,P(A_3\mid A_1\cap A_2)\cdots P(A_n\mid A_1\cap\cdots\cap A_{n-1}).

Proof. Induction on nn. The case n=2n=2 is the multiplication rule. Assume the identity for n1n-1 and write B=A1An1B=A_1\cap\cdots\cap A_{n-1}; note P(B)>0P(B)>0 implies each earlier intersection is positive too, by monotonicity. Then

P(A1An)=P(BAn)=P(B)P(AnB),P(A_1\cap\cdots\cap A_n)=P(B\cap A_n)=P(B)\,P(A_n\mid B),

and expanding P(B)P(B) by the induction hypothesis gives exactly the stated product. ∎

Example (draws without replacement, dependent). A box holds 1010 white and 1414 red balls (2424 total); draw 22 without replacement. With A=A=“first white,” B=B=“second white,”

P(AB)=P(A)P(BA)=1024923=90552=15920.163.P(A\cap B)=P(A)\,P(B\mid A)=\frac{10}{24}\cdot\frac{9}{23}=\frac{90}{552}=\frac{15}{92}\approx0.163.

The draws are dependent: removing a white ball changes the second draw’s odds from 1024\tfrac{10}{24} to 923\tfrac{9}{23}.

Example (defective parts, dependent). 4%4\% of parts are defective, so 96%96\% are non-defective; of the non-defective parts, 75%75\% are low quality. The probability a random part is non-defective and low quality is, by the multiplication rule, 0.960.75=0.72=72%0.96\cdot0.75=0.72=72\%.

Example (two children — a conditional-probability pitfall). A family has two children; assume the four birth orders {BB,BG,GB,GG}\{BB,BG,GB,GG\} are equally likely.

  • Given that at least one child is a boy, what is P(both boys)P(\text{both boys})? The condition is {BB,BG,GB}\{BB,BG,GB\} (three equally likely outcomes) and “both boys” is {BB}\{BB\}, so the answer is 13\tfrac13.
  • Given that the elder child is a boy, what is P(both boys)P(\text{both boys})? Now the condition is {BB,BG}\{BB,BG\} and the answer is 12\tfrac{1}{2}.

The two questions sound alike but condition on different events, and the answers genuinely differ. This is the classic warning that in P(AB)P(A\mid B) the event BB must be pinned down exactly.

Common pitfall (transposing the conditional). P(AB)P(A\mid B) and P(BA)P(B\mid A) are different numbers; equating them is the prosecutor’s fallacy. “The probability of this DNA match if the suspect is innocent is 11 in a million” (P(matchinnocent)P(\text{match}\mid\text{innocent})) is not “the probability the suspect is innocent given the match” (P(innocentmatch)P(\text{innocent}\mid\text{match})). Bayes’ theorem below is exactly the machine for converting one into the other, and it shows they can differ by orders of magnitude when the base rates differ.

Common pitfall (P(AB)P(A\mid B) vs P(AB)P(A\cap B)). The conditional P(AB)P(A\mid B) presumes BB has happened and lives in the shrunken world BB; the joint P(AB)P(A\cap B) makes no such assumption and lives in all of Ω\Omega. They are related by a factor of P(B)P(B) and are equal only when P(B)=1P(B)=1.

13.10 Independence

Definition (independence of two events). Events AA and BB are independent if

P(AB)=P(A)P(B).P(A\cap B)=P(A)\,P(B).

Equivalently, when P(B)>0P(B)>0, this says P(AB)=P(A)P(A\mid B)=P(A): knowing BB tells us nothing new about AA.

Independence is often justified physically (separate coins, distinct dice, draws with replacement, independently chosen hash keys), but the defining equation is the formal test — and physical intuition can mislead, so when in doubt, check the equation.

Example (independent, product rule). Roll a die twice: P(first 6 and second 6)=1616=136P(\text{first }6\text{ and second }6)=\tfrac16\cdot\tfrac16=\tfrac1{36}, matching direct enumeration of the 3636 outcomes.

Example (two boxes, independent). Box 1 has 22 white and 1010 red (1212 total); Box 2 has 88 white and 44 red (1212 total). Draw one ball from each. With A=A=“white from Box 1” and B=B=“white from Box 2” the draws are independent, so

P(AB)=P(A)P(B)=212812=1623=190.111.P(A\cap B)=P(A)\,P(B)=\frac{2}{12}\cdot\frac{8}{12}=\frac16\cdot\frac23=\frac19\approx0.111.

Theorem (incompatible \ne independent). If A,BA,B are incompatible and both have positive probability, then they are dependent.

Proof. Incompatibility means AB=A\cap B=\varnothing, so P(AB)=P()=0P(A\cap B)=P(\varnothing)=0. But independence would require P(AB)=P(A)P(B)>0P(A\cap B)=P(A)P(B)>0, since both factors are positive. The two are contradictory, so A,BA,B cannot be independent. ∎

This confirms the warning from the start of the lecture: incompatible events with positive probability are as far from independent as possible — the occurrence of one drives the other’s conditional probability to 00.

Remark (mutual vs. pairwise independence). For three or more events, pairwise independence (every pair satisfies the product rule) is weaker than mutual independence, which requires the product rule for every sub-collection, e.g. P(ABC)=P(A)P(B)P(C)P(A\cap B\cap C)=P(A)P(B)P(C) as well as the three pairwise equations. There are standard examples (two independent fair coins with C=C=“the coins agree”) that are pairwise but not mutually independent. Independence of “steps” in the multiplication principle is what makes P=piP=\prod p_i valid, as in the “at least one six” and De Méré computations.

Example (lottery — dependent and compatible). Of 100100 tickets, 55 win; you buy 22. Find P(at least one wins)P(\text{at least one wins}). The two “this ticket wins” events are compatible and dependent (sampling without replacement). The complement route is cleanest:

P(no win)=9510094990.9020,P(at least one)10.9020=0.098.P(\text{no win})=\frac{95}{100}\cdot\frac{94}{99}\approx0.9020,\qquad P(\text{at least one})\approx1-0.9020=0.098.

The general addition rule agrees: with P(A)=P(B)=5100P(A)=P(B)=\tfrac{5}{100} and P(AB)=51004990.00202P(A\cap B)=\tfrac{5}{100}\cdot\tfrac{4}{99}\approx0.00202, P(AB)=0.05+0.050.002020.098P(A\cup B)=0.05+0.05-0.00202\approx0.098. ✓

13.11 The law of total probability

Suppose a first stage of an experiment produces one of several hypotheses (causes, scenarios), and a later event AA has known probability under each. The law of total probability assembles these into P(A)P(A).

Theorem (law of total probability). Let H1,,HnH_1,\dots,H_n form a complete group (partition of Ω\Omega): pairwise incompatible, H1Hn=ΩH_1\cup\cdots\cup H_n=\Omega, and each P(Hi)>0P(H_i)>0. Then for any event AA,

P(A)=i=1nP(Hi)P(AHi).P(A)=\sum_{i=1}^n P(H_i)\,P(A\mid H_i).

Proof. Because the HiH_i cover Ω\Omega,

A=AΩ=A(i=1nHi)=i=1n(AHi),A=A\cap\Omega=A\cap\Big(\bigcup_{i=1}^n H_i\Big)=\bigcup_{i=1}^n(A\cap H_i),

using distributivity (Lecture 2). The sets AHiA\cap H_i are pairwise incompatible, since (AHi)(AHj)HiHj=(A\cap H_i)\cap(A\cap H_j)\subseteq H_i\cap H_j=\varnothing for iji\ne j. By finite additivity and then the multiplication rule (P(AHi)=P(Hi)P(AHi)P(A\cap H_i)=P(H_i)P(A\mid H_i), valid as P(Hi)>0P(H_i)>0),

P(A)=i=1nP(AHi)=i=1nP(Hi)P(AHi).P(A)=\sum_{i=1}^n P(A\cap H_i)=\sum_{i=1}^n P(H_i)\,P(A\mid H_i).\qquad\blacksquare

Read it as a weighted average: the chance of AA is the average of its conditional chances P(AHi)P(A\mid H_i), each weighted by how likely its hypothesis HiH_i is.

Probability tree for the law of total probability: branch on each hypothesis Hᵢ, then on A, giving P(A) = Σ P(Hᵢ)·P(A|Hᵢ)

Example (choose an urn, then a ball). Urn 1 holds 22 white and 1010 red; Urn 2 holds 88 white and 44 red. Pick an urn at random (P(H1)=P(H2)=12P(H_1)=P(H_2)=\tfrac12) and draw one ball. The probability it is white:

P(W)=P(H1)P(WH1)+P(H2)P(WH2)=12212+12812=121012=5120.417.P(W)=P(H_1)P(W\mid H_1)+P(H_2)P(W\mid H_2)=\tfrac12\cdot\tfrac{2}{12}+\tfrac12\cdot\tfrac{8}{12}=\tfrac12\cdot\tfrac{10}{12}=\tfrac{5}{12}\approx0.417.

A probability tree organizes exactly this computation — first branch on the hypothesis, then on AA, multiply along a path, add across paths ending in AA:

                 P(W|H1)=2/12
        P(H1)=1/2 ─────────── White   path prob = 1/2 · 2/12 = 2/24
       ┌──────── Urn 1
       │         └─────────── Red     1/2 · 10/12 = 10/24
 start ┤
       │         ┌─────────── White   1/2 · 8/12  = 8/24
       └──────── Urn 2
        P(H2)=1/2 ─────────── Red     1/2 · 4/12  = 4/24
                 P(R|H2)=4/12
   P(White) = 2/24 + 8/24 = 10/24 = 5/12 ✓

13.12 Bayes’ theorem

The law of total probability runs “forward”: from causes HiH_i to effect AA. Bayes’ theorem runs it backward, updating the probability of each cause after the effect is observed — the mathematics of learning from evidence.

Theorem (Bayes). Let H1,,HnH_1,\dots,H_n be a complete group with each P(Hi)>0P(H_i)>0, and let AA be an event with P(A)>0P(A)>0. Then for each ii,

P(HiA)=P(Hi)P(AHi)j=1nP(Hj)P(AHj)=P(Hi)P(AHi)P(A).P(H_i\mid A)=\frac{P(H_i)\,P(A\mid H_i)}{\displaystyle\sum_{j=1}^n P(H_j)\,P(A\mid H_j)}=\frac{P(H_i)\,P(A\mid H_i)}{P(A)}.

Proof. By the definition of conditional probability (using P(A)>0P(A)>0) and then the multiplication rule applied to the numerator,

P(HiA)=P(HiA)P(A)=P(Hi)P(AHi)P(A).P(H_i\mid A)=\frac{P(H_i\cap A)}{P(A)}=\frac{P(H_i)\,P(A\mid H_i)}{P(A)}.

Finally substitute the law of total probability P(A)=jP(Hj)P(AHj)P(A)=\sum_j P(H_j)P(A\mid H_j) for the denominator. ∎

Vocabulary. P(Hi)P(H_i) is the prior (belief before evidence), P(AHi)P(A\mid H_i) the likelihood (how well hypothesis ii predicts the evidence), and P(HiA)P(H_i\mid A) the posterior (updated belief). Bayes’ theorem is the formal rule for turning prior belief + data into posterior belief.

Odds form (two hypotheses). For HH and H\overline H, dividing the two Bayes formulas cancels the shared denominator P(A)P(A) and yields a memorable multiplicative update:

P(HA)P(HA)posterior odds=P(H)P(H)prior oddsP(AH)P(AH)likelihood ratio.\underbrace{\frac{P(H\mid A)}{P(\overline H\mid A)}}_{\text{posterior odds}} =\underbrace{\frac{P(H)}{P(\overline H)}}_{\text{prior odds}}\cdot \underbrace{\frac{P(A\mid H)}{P(A\mid \overline H)}}_{\text{likelihood ratio}}.

Worked example: a medical test (with a natural-frequency cross-check)

A disease affects 1%1\% of a population, so the prior is P(D)=0.01P(D)=0.01. A test has sensitivity P(+D)=0.99P(+\mid D)=0.99 (it catches 99%99\% of true cases) and false-positive rate P(+D)=0.05P(+\mid\overline D)=0.05. A randomly chosen person tests positive. What is P(D+)P(D\mid+)?

Step 1 — total probability of a positive test.

P(+)=P(D)P(+D)+P(D)P(+D)=0.010.99+0.990.05=0.0099+0.0495=0.0594.P(+)=P(D)P(+\mid D)+P(\overline D)P(+\mid\overline D)=0.01\cdot0.99+0.99\cdot0.05=0.0099+0.0495=0.0594.

Step 2 — Bayes.

P(D+)=P(D)P(+D)P(+)=0.00990.05940.167.P(D\mid+)=\frac{P(D)P(+\mid D)}{P(+)}=\frac{0.0099}{0.0594}\approx0.167.

Despite a “99%99\% accurate” test, a positive result gives only about a 16.7%16.7\% chance of actually having the disease. The reason is the base rate: the disease is rare, so the few genuine positives are swamped by false positives generated from the huge healthy majority.

Natural-frequency tree for the medical test: of 10,000 people, 100 are sick (99 test positive) and 9,900 healthy (495 test positive), so P(sick | +) = 99/(99+495) ≈ 16.7%

Natural-frequency cross-check. Abandon fractions and imagine a concrete cohort of 10,00010{,}000 people. This “confusion matrix” is exactly the 2×22\times2 contingency table used to evaluate classifiers in machine learning:

Test ++ Test - Row total
Diseased (1%1\%) 9999 (true pos.) 11 (false neg.) 100100
Healthy (99%99\%) 495495 (false pos.) 9,4059{,}405 (true neg.) 9,9009{,}900
Column total 594594 9,4069{,}406 10,00010{,}000

Of the 594594 people who test positive, only 9999 are truly ill, so P(D+)=99/594=0.160.167P(D\mid+)=99/594=0.1\overline{6}\approx0.167 — identical to Bayes, and far easier to feel. The odds form gives the same answer in one line: prior odds 0.01/0.99=1/990.01/0.99=1/99, likelihood ratio 0.99/0.05=19.80.99/0.05=19.8, posterior odds 19.8/99=0.219.8/99=0.2, hence posterior probability 0.2/(1+0.2)=1/60.1670.2/(1+0.2)=1/6\approx0.167.

CS / ML connection. In classifier terms the table’s quantities are named: recall (sensitivity) =P(+D)=P(+\mid D), and precision =P(D+)=99/5940.167=P(D\mid+)=99/594\approx0.167. A spam filter faces the same arithmetic — a rare event (a genuine phishing mail) with an imperfect detector — and a naive Bayes classifier is literally Bayes’ theorem applied under a simplifying independence assumption on the features (words). Base-rate neglect is the human bug that Bayesian reasoning fixes.

13.13 The birthday problem

In a room of nn people, how likely is it that two share a birthday? The answer is famously larger than intuition suggests, and it is the exact model of hash collisions.

Setup. Assume 365365 equally likely birthdays, independent across people (ignore leap days and twins). The sample space of birthday assignments has 365n365^{\,n} equally likely elements. Let An=A_n=“some two of the nn people share a birthday.” Compute the complement An=\overline{A_n}=“all nn birthdays are distinct” — far easier to count.

Derivation. Assigning nn distinct birthdays is an ordered selection of nn days from 365365 without repetition, i.e. a kk-permutation with k=nk=n:

P(An)=P(365,n)365n=365364(365n+1)365n=j=0n1365j365=j=1n1(1j365).P(\overline{A_n})=\frac{P(365,n)}{365^{\,n}}=\frac{365\cdot364\cdots(365-n+1)}{365^{\,n}} =\prod_{j=0}^{n-1}\frac{365-j}{365}=\prod_{j=1}^{n-1}\Big(1-\frac{j}{365}\Big).

Therefore P(An)=1P(An)P(A_n)=1-P(\overline{A_n}). Tabulating:

nn P(all distinct)P(\text{all distinct}) P(some match)P(\text{some match})
10 0.8831 0.1169
20 0.5886 0.4114
23 0.4927 0.5073
30 0.2937 0.7063
40 0.1088 0.8912
50 0.0296 0.9704
70 0.0008 0.9992

At n=23n=23 the probability of a shared birthday first exceeds 12\tfrac12 — only 2323 people, not the 183183 (half of 365365) that intuition often guesses. By n=70n=70 a match is virtually certain.

Curve of P(shared birthday) against the number of people, crossing the 50% line at 23 people (50.7%)

Why so few? A shared birthday needs only some pair to coincide, and nn people form (n2)=n(n1)2\binom{n}{2}=\dfrac{n(n-1)}{2} pairs — a quantity that grows like n2n^2. For n=23n=23 that is (232)=253\binom{23}{2}=253 pairs, already comparable to 365365. The standard approximation makes this precise: using 1xex1-x\approx e^{-x},

P(An)=j=1n1(1j365)exp ⁣(1365j=1n1j)=exp ⁣(n(n1)2365).P(\overline{A_n})=\prod_{j=1}^{n-1}\Big(1-\tfrac{j}{365}\Big)\approx\exp\!\Big(-\tfrac1{365}\sum_{j=1}^{n-1}j\Big)=\exp\!\Big(-\frac{n(n-1)}{2\cdot365}\Big).

For n=23n=23: 23222365=2533650.693\dfrac{23\cdot22}{2\cdot365}=\dfrac{253}{365}\approx0.693, and e0.6930.500e^{-0.693}\approx0.500, so P(A23)0.50P(A_{23})\approx0.50 — matching the exact 0.50730.5073.

CS connection (hash collisions and the birthday attack). Replace 365365 by the number NN of hash buckets (or possible hash values). The same computation shows that once about N\sqrt{N} items have been hashed, a collision becomes more likely than not. This is why a hash function with a bb-bit output (N=2bN=2^b) offers only about 2b/22^{b/2} collision resistance, and why the birthday attack forces cryptographic hash lengths to be doubled: to resist collisions at the 21282^{128} level, one needs a 256256-bit hash. The birthday problem is thus a load-bearing calculation in the design of hash tables and cryptographic digests.

13.14 The Monty Hall problem

A game show has three doors: behind one is a car, behind the other two are goats. You pick a door. The host — who knows what is behind each door — opens a different door, always revealing a goat, and offers you the chance to switch to the remaining unopened door. Should you switch?

State the rules precisely (they matter). The standard problem assumes:

  1. the car is equally likely behind any door;
  2. the host always opens a door you did not pick and always reveals a goat;
  3. if your initial pick hides the car (so the host has two goat doors to choose from), the host picks between them uniformly at random.

Under these rules the answer is that switching wins with probability 23\tfrac23, staying only 13\tfrac13. Two independent arguments confirm it.

Argument 1 (enumeration on the initial pick). Your first choice is right (car) with probability 13\tfrac13 and wrong (goat) with probability 23\tfrac23.

  • If your first pick was the car (13\tfrac13): the other unopened door hides a goat, so switching loses.
  • If your first pick was a goat (23\tfrac23): the host is forced to reveal the other goat, so the remaining unopened door hides the car, and switching wins.

Hence P(winswitch)=P(first pick was a goat)=23P(\text{win}\mid\text{switch})=P(\text{first pick was a goat})=\tfrac23.

Argument 2 (Bayes). Say you pick door 1 and the host opens door 3. Let Ci=C_i=“car behind door ii” (priors 13\tfrac13 each) and O3=O_3=“host opens door 3.” The likelihoods encode the rules:

Hypothesis P(O3Ci)P(O_3\mid C_i) reason
C1C_1 (your door) 12\tfrac12 host free to open 2 or 3, chooses randomly
C2C_2 11 host cannot open 1 (yours) or 2 (car) → must open 3
C3C_3 00 host never opens the car’s door

By total probability P(O3)=1312+131+130=16+13=12P(O_3)=\tfrac13\cdot\tfrac12+\tfrac13\cdot1+\tfrac13\cdot0=\tfrac16+\tfrac13=\tfrac12. Then Bayes gives

P(C1O3)=131212=13,P(C2O3)=13112=23.P(C_1\mid O_3)=\frac{\tfrac13\cdot\tfrac12}{\tfrac12}=\frac13,\qquad P(C_2\mid O_3)=\frac{\tfrac13\cdot1}{\tfrac12}=\frac23.

Staying keeps door 1 with win probability 13\tfrac13; switching moves to door 2 with win probability 23\tfrac23. ∎

Why intuition fails (the crucial point). The two remaining doors are not symmetric, so “it’s now 50-50” is wrong. The host’s action carries information: when your first pick was a goat (probability 23\tfrac23), the host is forced to expose the only other goat, effectively pointing at the car. Switching converts your initial 23\tfrac23 chance of being wrong into a 23\tfrac23 chance of winning. If instead the host opened a door at random and merely happened to reveal a goat, the information would be different and the odds would indeed become 12\tfrac12 — which is why stating the rules is not pedantry.

13.15 Random variables and expectation

Often we care not about which outcome occurs but about a number attached to it — the sum of two dice, the number of collisions in a hash table, the running time of a randomized algorithm.

Definition (random variable). A random variable on a sample space Ω\Omega is a function X:ΩRX:\Omega\to\mathbb{R} assigning a real number to each outcome. For discrete Ω\Omega its probability mass function is pX(x)=P(X=x)=P({ω:X(ω)=x})p_X(x)=P(X=x)=P(\{\omega:X(\omega)=x\}); the masses are non-negative and sum to 11 over the possible values.

Example. For one die, X(ω)=ωX(\omega)=\omega has pX(k)=16p_X(k)=\tfrac16 for k=1,,6k=1,\dots,6. For two dice, S=S=“sum” is a random variable with the mass function tabulated in Problem 2.

Indicator variables. The indicator of an event AA is 1A(ω)=1\mathbf 1_A(\omega)=1 if ωA\omega\in A and 00 otherwise. It converts an event into a {0,1}\{0,1\}-valued random variable and is the bridge between events and expectations.

Definition (expectation). The expected value (mean) of a discrete random variable XX is the probability-weighted average of its values,

E[X]=xxP(X=x)=ωΩX(ω)P({ω}).E[X]=\sum_{x}x\,P(X=x)=\sum_{\omega\in\Omega}X(\omega)\,P(\{\omega\}).

It is the “long-run average” the value of XX approaches when the experiment is repeated many times (this is what the law of large numbers guarantees).

Example (one die). E[X]=k=16k16=1+2+3+4+5+66=216=3.5E[X]=\sum_{k=1}^{6}k\cdot\tfrac16=\tfrac{1+2+3+4+5+6}{6}=\tfrac{21}{6}=3.5. The mean 3.53.5 is not itself an attainable value — expectation is an average, not a prediction of any single roll.

Example (indicator). E[1A]=1P(A)+0P(A)=P(A)E[\mathbf 1_A]=1\cdot P(A)+0\cdot P(\overline A)=P(A). The expected value of an indicator is just the probability of its event — the identity that makes the next theorem so useful.

Theorem (linearity of expectation). For any random variables X,YX,Y on the same finite Ω\Omega and constants a,bRa,b\in\mathbb R,

E[aX+bY]=aE[X]+bE[Y].E[aX+bY]=a\,E[X]+b\,E[Y].

Crucially, this holds whether or not XX and YY are independent.

Proof. Using the outcome-sum form of expectation and rearranging a finite sum,

E[aX+bY]=ωΩ(aX(ω)+bY(ω))P({ω})=aωX(ω)P({ω})+bωY(ω)P({ω})=aE[X]+bE[Y].E[aX+bY]=\sum_{\omega\in\Omega}\big(aX(\omega)+bY(\omega)\big)P(\{\omega\}) =a\sum_{\omega}X(\omega)P(\{\omega\})+b\sum_{\omega}Y(\omega)P(\{\omega\})=a\,E[X]+b\,E[Y].

The only facts used are the distributive law and that a finite sum can be split — no independence anywhere. ∎

Example (sum of two dice, via linearity). Let X1,X2X_1,X_2 be the two dice. Then E[X1+X2]=E[X1]+E[X2]=3.5+3.5=7E[X_1+X_2]=E[X_1]+E[X_2]=3.5+3.5=7, instantly — no need to weight the 1111 sum-values by the table in Problem 2 (though doing so also gives 252/36=7252/36=7). Linearity turns a messy convolution into one line.

Example (expected number of birthday matches). Among nn people, let XX count the pairs sharing a birthday. Writing X=pairs (i,j)1ijX=\sum_{\text{pairs }(i,j)}\mathbf 1_{ij}, where 1ij\mathbf 1_{ij} indicates that persons i,ji,j match, linearity and E[1ij]=P(match)=1365E[\mathbf 1_{ij}]=P(\text{match})=\tfrac1{365} give

E[X]=(n2)1365=n(n1)2365.E[X]=\binom{n}{2}\cdot\frac1{365}=\frac{n(n-1)}{2\cdot365}.

For n=23n=23, E[X]=253/3650.69E[X]=253/365\approx0.69 — the very exponent that appeared in the birthday approximation, now explained: matches become likely exactly when the expected number of matching pairs reaches order 11. (Note the pair-events are not independent, yet linearity still applies — its great strength.)

Bernoulli and binomial. An event AA with P(A)=pP(A)=p defines a Bernoulli variable 1A\mathbf 1_A with E[1A]=pE[\mathbf 1_A]=p. Repeating nn independent Bernoulli trials, the count of successes XX is binomial, P(X=k)=(nk)pk(1p)nkP(X=k)=\binom{n}{k}p^k(1-p)^{n-k}, and writing X=1A1++1AnX=\mathbf 1_{A_1}+\cdots+\mathbf 1_{A_n} gives by linearity

E[X]=i=1nP(Ai)=np.E[X]=\sum_{i=1}^n P(A_i)=np.

For example, in 1010 fair coin flips the expected number of heads is 1012=510\cdot\tfrac12=5.

Variance and standard deviation

The mean alone does not capture spread. The variance of XX is the expected squared deviation from the mean,

Var(X)=E[(XE[X])2]=E[X2](E[X])2 0,\operatorname{Var}(X)=E\big[(X-E[X])^2\big]=E[X^2]-(E[X])^2\ \ge 0,

and the standard deviation σ(X)=Var(X)\sigma(X)=\sqrt{\operatorname{Var}(X)} is in the same units as XX. For the single die, Var=35122.92\operatorname{Var}=\tfrac{35}{12}\approx2.92 and σ1.71\sigma\approx1.71. Two handy rules: Var(aX+b)=a2Var(X)\operatorname{Var}(aX+b)=a^2\operatorname{Var}(X), and for independent X,YX,Y, Var(X+Y)=Var(X)+Var(Y)\operatorname{Var}(X+Y)=\operatorname{Var}(X)+\operatorname{Var}(Y).

For a dataset x1,,xNx_1,\dots,x_N — the descriptive-statistics view used in Lab 7 — the same formula with equal weights 1/N1/N gives the population mean, variance, and standard deviation

μ=1Nixi,σ2=1Ni(xiμ)2,σ=σ2;\mu=\frac1N\sum_i x_i,\qquad \sigma^2=\frac1N\sum_i (x_i-\mu)^2,\qquad \sigma=\sqrt{\sigma^2};

the sample variance divides by N1N-1 instead of NN (an unbiased estimate when the data are a sample, not the whole population). Variance also controls how fast averages converge (Chebyshev’s inequality, concentration bounds) — a theme of the next course, and the reason randomized algorithms are reliably fast, not merely fast on average.

A short history

Games of chance are ancient, but their mathematics is not. Gerolamo Cardano (c. 1564) wrote the first analysis of dice odds. The subject proper was born in 1654 in the correspondence between Blaise Pascal and Pierre de Fermat, prompted by exactly the kind of gambling puzzle de Méré posed above. Christiaan Huygens wrote the first textbook (1657); Jacob Bernoulli proved the first law of large numbers (published 1713), rigorously linking probability to long-run frequency; Thomas Bayes’ essay on inverse probability appeared posthumously (1763); and Pierre-Simon Laplace systematized the classical definition around 1812. The modern axiomatic foundation — the three axioms of this lecture, freeing probability from any reliance on symmetry or frequency — was laid by Andrey Kolmogorov in 1933, and it is his framework we have used throughout.

Chapter summary

  • A random experiment has a sample space Ω\Omega of elementary outcomes; an event is a subset AΩA\subseteq\Omega. Events are sets, so the union/intersection/ complement algebra and De Morgan’s laws of Lectures 1–2 transfer verbatim (the event–set dictionary).
  • Event types: certain (Ω\Omega), impossible (\varnothing), compatible vs. incompatible (AB=A\cap B=\varnothing), complementary A,AA,\overline A, a complete group (partition, cf. Lecture 3), and independent vs. dependent.
  • Classical probability P(A)=A/ΩP(A)=|A|/|\Omega| for equally likely outcomes reduces probability to counting; the statistical view estimates P(A)P(A) by relative frequency (law of large numbers) when symmetry is unavailable.
  • Combinatorics. Multiplication principle \Rightarrow permutations n!n!, arrangements P(n,k)=n!(nk)!P(n,k)=\dfrac{n!}{(n-k)!}, combinations (nk)=n!k!(nk)!\dbinom{n}{k}=\dfrac{n!}{k!(n-k)!} (derived via P(n,k)=(nk)k!P(n,k)=\binom{n}{k}k!); Pascal’s identity (nk)=(n1k1)+(n1k)\binom{n}{k}=\binom{n-1}{k-1}+\binom{n-1}{k}.
  • Kolmogorov’s axioms: P(A)0P(A)\ge0, P(Ω)=1P(\Omega)=1, additivity over incompatible events — from which we proved P()=0P(\varnothing)=0, P(A)=1P(A)P(\overline A)=1-P(A), 0P(A)10\le P(A)\le1, monotonicity, the addition rule P(AB)=P(A)+P(B)P(AB)P(A\cup B)=P(A)+P(B)-P(A\cap B) (a probabilistic inclusion–exclusion), its three-event form, and Boole’s inequality (union bound).
  • Conditional probability P(AB)=P(AB)P(B)P(A\mid B)=\dfrac{P(A\cap B)}{P(B)} shrinks the sample space to BB; the multiplication rule P(AB)=P(B)P(AB)P(A\cap B)=P(B)P(A\mid B) and its chain rule generalization follow.
  • Independence: P(AB)=P(A)P(B)P(A\cap B)=P(A)P(B), equivalently P(AB)=P(A)P(A\mid B)=P(A). Incompatible events of positive probability are provably dependent.
  • Law of total probability P(A)=iP(Hi)P(AHi)P(A)=\sum_i P(H_i)P(A\mid H_i) (proved via a partition) and Bayes’ theorem P(HiA)=P(Hi)P(AHi)jP(Hj)P(AHj)P(H_i\mid A)=\dfrac{P(H_i)P(A\mid H_i)}{\sum_j P(H_j)P(A\mid H_j)} (proved from it) turn priors + likelihoods into posteriors; the odds form multiplies prior odds by the likelihood ratio.
  • Three set pieces: the birthday problem (n=23P0.507n=23\Rightarrow P\approx0.507; models hash/birthday-attack collisions at N\sqrt N), Monty Hall (switch to win 23\tfrac23), and the medical-test Bayes calculation (P(D+)16.7%P(D\mid+)\approx16.7\%; base-rate neglect).
  • Random variables X:ΩRX:\Omega\to\mathbb R and expectation E[X]=xxP(X=x)E[X]=\sum_x xP(X=x); linearity of expectation E[aX+bY]=aE[X]+bE[Y]E[aX+bY]=aE[X]+bE[Y] holds without independence; a binomial count has E[X]=npE[X]=np.

Exercises

Warm-up

  1. Roll one fair die. Write Ω\Omega, and as subsets the events A=A=“odd,” B=B=“at least 44.” Compute P(A)P(A), P(B)P(B), P(AB)P(A\cap B), P(AB)P(A\cup B) and verify the addition rule.
  2. Give Ω\Omega for tossing three distinguishable coins and its size. Find the probability of exactly two heads.
  3. Explain in one sentence each the difference between (a) incompatible and independent events, and (b) P(AB)P(A\mid B) and P(AB)P(A\cap B).
  4. A committee of 44 is chosen from 1212 people. How many committees are possible? If instead the four take distinct roles (chair, secretary, treasurer, webmaster), how many role-assignments are possible?
  5. From a standard deck, find P(red)P(\text{red}), P(queen)P(\text{queen}), and P(red or queen)P(\text{red or queen}).

Standard

  1. (Derive a rule.) Using only Kolmogorov’s axioms, prove P(AB)=P(A)+P(B)P(AB)P(A\cup B)=P(A)+P(B)-P(A\cap B), and state where you use additivity.
  2. Two fair dice are rolled. Find P(sum=9)P(\text{sum}=9), P(sum is even)P(\text{sum is even}), and P(sum=9sum is odd)P(\text{sum}=9\mid \text{sum is odd}).
  3. An urn has 55 red, 33 green, 22 blue balls; draw 33 without replacement. Find the probability of (a) all red, (b) one of each colour, (c) at least one blue.
  4. A box has 88 good and 22 defective chips; draw 22 without replacement. Find the probability both are good, first via the multiplication rule and again via combinations, and confirm the answers agree.
  5. Cards: two are drawn without replacement. Find P(both hearts)P(\text{both hearts}) and P(second is a heartfirst is a heart)P(\text{second is a heart}\mid \text{first is a heart}).
  6. (Total probability.) Factory lines I, II, III make 50%,30%,20%50\%,30\%,20\% of output with defect rates 2%,3%,5%2\%,3\%,5\%. Find the probability a random item is defective.
  7. (Bayes.) For Exercise 11, a random item is found defective. Which line most probably produced it? Give all three posterior probabilities.
  8. A test for a condition present in 2%2\% of people has sensitivity 95%95\% and false-positive rate 10%10\%. Find P(condition+)P(\text{condition}\mid+) by Bayes, and cross-check with a natural-frequency table of 10,00010{,}000 people.
  9. Show, using indicators and linearity, that the expected number of sixes in nn rolls of a fair die is n/6n/6. Evaluate for n=30n=30.

Challenge

  1. (Birthday variant.) In a room of nn people, let A=A=“someone shares your birthday.” Show P(A)=1(364/365)n1P(A)=1-(364/365)^{\,n-1} and find the smallest nn making P(A)12P(A)\ge\tfrac12. Explain why this nn is far larger than 2323.
  2. (Monty Hall, kk doors.) Generalize Monty Hall to NN doors (one car), where after your pick the host opens exactly one goat door and offers a single switch. Show switching wins with probability N1N(N2)\dfrac{N-1}{N(N-2)} for N3N\ge3, and compare staying’s 1/N1/N.
  3. (Inclusion–exclusion.) Three fair dice are rolled. Using the three-event addition rule, find the probability that at least one die shows a six.
  4. (De Méré, generalized.) For how many rolls rr of a single die does P(at least one six in r rolls)P(\text{at least one six in }r\text{ rolls}) first exceed 12\tfrac12? Justify with the complement rule.
  5. (Prosecutor’s fallacy.) A DNA test declares a match with probability 11 in 1,000,0001{,}000{,}000 for a random innocent person. In a database of 1010 million innocent people, a match is found. Use the union bound (or expectation) to explain why “one in a million” does not mean the matched person is almost surely guilty.
  6. (Pairwise vs. mutual independence.) Toss two fair coins; let A=A=“first is heads,” B=B=“second is heads,” C=C=“the two coins agree.” Show A,B,CA,B,C are pairwise independent but not mutually independent.

Selected answers & hints

  • 1. Ω={1,,6}\Omega=\{1,\dots,6\}; A={1,3,5},B={4,5,6}A=\{1,3,5\},B=\{4,5,6\}; P(A)=P(B)=12P(A)=P(B)=\tfrac12, AB={5}A\cap B=\{5\} so P(AB)=16P(A\cap B)=\tfrac16, AB={1,3,4,5,6}A\cup B=\{1,3,4,5,6\} so P(AB)=56P(A\cup B)=\tfrac56; check 12+1216=56\tfrac12+\tfrac12-\tfrac16=\tfrac56. ✓
  • 2. Ω=23=8|\Omega|=2^3=8; exactly two heads is (32)=3\binom{3}{2}=3 outcomes, probability 38\tfrac38.
  • 4. Committees: (124)=495\binom{12}{4}=495. Distinct roles: P(12,4)=1211109=11,880=4954!P(12,4)=12\cdot11\cdot10\cdot9=11{,}880=495\cdot4!.
  • 5. 2652=12\tfrac{26}{52}=\tfrac12; 452=113\tfrac{4}{52}=\tfrac1{13}; red-or-queen =2652+452252=2852=713=\tfrac{26}{52}+\tfrac{4}{52}-\tfrac{2}{52}=\tfrac{28}{52}=\tfrac7{13}.
  • 7. P(sum=9)=436=19P(\text{sum}=9)=\tfrac4{36}=\tfrac19; P(even)=1836=12P(\text{even})=\tfrac{18}{36}=\tfrac12; sum 99 is odd, so P(sum=9odd)=4/3618/36=418=29P(\text{sum}=9\mid\text{odd})=\tfrac{4/36}{18/36}=\tfrac{4}{18}=\tfrac29.
  • 8. Total (103)=120\binom{10}{3}=120. (a) (53)/120=10/120=112\binom53/120=10/120=\tfrac1{12}. (b) (51)(31)(21)/120=30/120=14\binom51\binom31\binom21/120=30/120=\tfrac14. (c) complement (no blue) =(83)/120=56/120=715=\binom83/120=56/120=\tfrac{7}{15}, so P(1 blue)=815P(\ge1\text{ blue})=\tfrac{8}{15}.
  • 9. 81079=5690=2845\tfrac{8}{10}\cdot\tfrac{7}{9}=\tfrac{56}{90}=\tfrac{28}{45}; and (82)/(102)=28/45\binom82/\binom{10}2=28/45. ✓
  • 11. 0.5(0.02)+0.3(0.03)+0.2(0.05)=0.010+0.009+0.010=0.0290.5(0.02)+0.3(0.03)+0.2(0.05)=0.010+0.009+0.010=0.029.
  • 12. Posteriors == each term over 0.0290.029: line I 0.0100.0290.345\tfrac{0.010}{0.029}\approx0.345, II 0.0090.0290.310\tfrac{0.009}{0.029}\approx0.310, III 0.0100.0290.345\tfrac{0.010}{0.029}\approx0.345. Lines I and III tie as most probable.
  • 13. P(+)=0.02(0.95)+0.98(0.10)=0.019+0.098=0.117P(+)=0.02(0.95)+0.98(0.10)=0.019+0.098=0.117; P(cond+)=0.019/0.1170.162P(\text{cond}\mid+)=0.019/0.117\approx0.162. Cohort of 10,00010{,}000: 200200 affected → 190190 true positives; 9,8009{,}800 unaffected → 980980 false positives; 190/(190+980)=190/11700.162190/(190+980)=190/1170\approx0.162. ✓
  • 15. Each other person misses your birthday with probability 364/365364/365, independently, so P(A)=(364/365)n1P(\overline A)=(364/365)^{n-1}. Solve (364/365)n112(364/365)^{n-1}\le\tfrac12: n1ln2/ln(365/364)252.65n-1\ge\ln 2/\ln(365/364)\approx252.65, so n=254n=254. It is huge compared to 2323 because only n1n-1 comparisons target your fixed day, versus (n2)\binom{n}{2} comparisons among all pairs in the classic problem.
  • 17. P(1 six)=1(5/6)3=1125/216=91/2160.421P(\ge1\text{ six})=1-(5/6)^3=1-125/216=91/216\approx0.421; the three-event inclusion–exclusion gives 33621636216+1216=10818+1216=912163\cdot\tfrac{36}{216}-3\cdot\tfrac{6}{216}+\tfrac{1}{216}=\tfrac{108-18+1}{216}=\tfrac{91}{216}, agreeing.
  • 18. 1(5/6)r>12    (5/6)r<12    r>ln2/ln(6/5)3.801-(5/6)^r>\tfrac12\iff(5/6)^r<\tfrac12\iff r>\ln2/\ln(6/5)\approx3.80, so r=4r=4 (matching De Méré’s Bet A, P0.518P\approx0.518).
  • 20. P(A)=P(B)=P(C)=12P(A)=P(B)=P(C)=\tfrac12; pairwise P(AB)=14=P(A)P(B)P(A\cap B)=\tfrac14=P(A)P(B), P(AC)=P({HH})=14=P(A)P(C)P(A\cap C)=P(\{HH\})=\tfrac14=P(A)P(C), likewise B,CB,C. But P(ABC)=P({HH})=1418=P(A)P(B)P(C)P(A\cap B\cap C)=P(\{HH\})=\tfrac14\ne\tfrac18=P(A)P(B)P(C), so not mutually independent.

Further reading

  • K. H. Rosen, Discrete Mathematics and Its Applications — chapters on Discrete Probability and Counting (the multiplication principle, permutations/combinations, Bayes’ theorem, and expected value are developed at this level).
  • S. Ross, A First Course in Probability — a fuller, rigorous treatment of axioms, conditional probability, independence, and random variables.
  • C. M. Grinstead and J. L. Snell, Introduction to Probability (freely available) — excellent worked problems, including Monty Hall and the birthday problem.
  • For the algorithmic side: M. Mitzenmacher and E. Upfal, Probability and Computing — the union bound, hashing, and randomized algorithms in depth.

Lectures/CDM-L13.md · 62.0 KB · updated 2026-08-01 20:55