






































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







































































Roughly speaking, probability theory deals with experiments whose outcome are not predictable with certainty. We often call such experiments random experiments. They are subject to chance. Using a mathematical theory of probability, we may be able to calculate the likelihood of some event. In the introduction to his classical book [1] (first published in 1888), Joseph Bertrand (1822–1900) writes (translated from French to English):
“How dare we talk about the laws of chance (in French: le hasard)? Isn’t chance the antithesis of any law? In rejecting this definition, I will not propose any alternative. On a vaguely defined subject, one can reason with authority. ...”
Of course, Bertrand’s words are supposed to provoke the reader. But it does seem paradoxical that anyone could claim to have a precise theory about chance! It is not my intention to engage in a philosophical discussion about the nature of chance. Instead, I will try to explain how it is possible to build some mathematical tools that can be used to reason rigorously about phenomema that are subject to chance. These tools belong to probability theory. These days, many fields in computer science such as machine learning, cryptography, computational linguistics, computer vision, robotics, and of course algorithms, rely a lot on probability theory. These fields are also a great source of new problems that stimulate the discovery of new methods and new theories in probability theory. Although this is an oversimplification that ignores many important contributors, one might say that the development of probability theory has gone through four eras whose key figures are: Pierre de Fermat and Blaise Pascal, Pierre–Simon Laplace, and Andrey Kolmogorov. Of course, Gauss should be added to the list; he made major contributions to nearly every area of mathematics and physics during his life- time. To be fair, Jacob Bernoulli, Abraham de Moivre, Pafnuty Chebyshev, Alek- sandr Lyapunov, Andrei Markov, Emile Borel, and Paul L´evy should also be added to the list.
329
330 8 An Introduction to Discrete Probability
Fig. 8.1 Pierre de Fermat (1601–1665) (left), Blaise Pascal (1623–1662) (middle left), Pierre– Simon Laplace (1749–1827) (middle right), Andrey Nikolaevich Kolmogorov (1903–1987) (right).
Before Kolmogorov, probability theory was a subject that still lacked precise def- initions. In1933, Kolmogorov provided a precise axiomatic approach to probability theory which made it into a rigorous branch of mathematics with even more appli- cations than before! The first basic assumption of probability theory is that even if the outcome of an experiment is not known in advance, the set of all possible outcomes of an experi- ment is known. This set is called the sample space or probability space. Let us begin with a few examples.
Example 8.1. If the experiment consists of flipping a coin twice, then the sample space consists of all four strings
W = {HH, HT, TH, TT},
where H stands for heads and T stands for tails. If the experiment consists in flipping a coin five times, then the sample space W is the set of all strings of length five over the alphabet {H, T}, a set of 2 5 = 32 strings,
W = {HHHHH, THHHH, HTHHH, TTHHH,... , TTTTT}.
Example 8.2. If the experiment consists in rolling a pair of dice, then the sample space W consists of the 36 pairs in the set
W = D ⇥ D
with D = { 1 , 2 , 3 , 4 , 5 , 6 },
where the integer i 2 D corresponds to the number (indicated by dots) on the face of the dice facing up, as shown in Figure 8.2. Here we assume that one dice is rolled first and then another dice is rolled second.
Example 8.3. In the game of bridge, the deck has 52 cards and each player receives a hand of 13 cards. Let W be the sample space of all possible hands. This time it is not possible to enumerate the sample space explicitly. Indeed, there are
332 8 An Introduction to Discrete Probability
If we assume in Example 8.2, that our dice are “fair,” namely that each of the six possibilities for a particular dice has probability 1/6 , then each of the 36 rolls w 2 W has probability
Pr(w) =
We can also consider “loaded dice” in which there is a different distribution of probabilities. For example, let
Pr 1 ( 1 ) = Pr 1 ( 6 ) =
Pr 1 ( 2 ) = Pr 1 ( 3 ) = Pr 1 ( 4 ) = Pr 1 ( 5 ) =
These probabilities add up to 1, so Pr 1 is a probability distribution on D. We can assign probabilities to the elements of W = D ⇥ D by the rule
Pr 11 (d, d 0 ) = Pr 1 (d)Pr 1 (d 0 ).
We can easily check that
w 2 W
Pr 11 (w) = 1 ,
so Pr 11 is indeed a probability distribution on W. For example, we get
Pr 11 ( 6 , 3 ) = Pr 1 ( 6 )Pr 1 ( 3 ) =
Let us summarize all this with the following definition.
Definition 8.1. A finite discrete probability space (or finite discrete sample space) is a finite set W of outcomes or elementary events w 2 W , together with a function Pr : W! R, called probability measure (or probability distribution) satisfying the following properties:
0 Pr(w) 1 for all w 2 W.
w 2 W
Pr(w) = 1.
The uniform probability distribution on W is the probability measure given by Pr(w) = 1 /|W | for all w 2 W. An event is any subset A of W. The probability of an event A is defined as
w 2 A
Pr(w).
Definition 8.1 immediately implies that
Pr( 0 /) = 0 Pr(W ) = 1.
8.1 Sample Space, Outcomes, Events, Probability 333
The event W is called the certain event. In general there are other events A such that Pr(A) = 1.
Remark: Even though the term probability distribution is commonly used, this is not a good practice because there is also a notion of (cumulative) distribution func- tion of a random variable (see Section 8.3, Definition 8.6), and this is a very different object (the domain of the distribution function of a random variable is R, not W ). For another example, if we consider the event
A = {HTTTT, THTTT, TTHTT, TTTHT, TTTTH}
that in flipping a coin five times, heads turns up exactly once, the probability of this event is
Pr(A) =
If we use the probability measure Pr on the sample space W of pairs of dice, the probability of the event of having doubles
B = {( 1 , 1 ), ( 2 , 2 ), ( 3 , 3 ), ( 4 , 4 ), ( 5 , 5 ), ( 6 , 6 )},
is
Pr(B) = 6 ·
However, using the probability measure Pr 11 , we obtain
Pr 11 (B) =
Loading the dice makes the event “having doubles” more probable. It should be noted that a definition slightly more general than Definition 8.1 is needed if we want to allow W to be infinite. In this case, the following definition is used.
Definition 8.2. A discrete probability space (or discrete sample space) is a triple (W , F , Pr) consisting of:
8.1 Sample Space, Outcomes, Events, Probability 335
Pr(A [ B) = Pr(A) + Pr(B) Pr(A \ B) Pr(A) = 1 Pr(A).
Furthermore, if A ✓ B, then Pr(A) Pr(B).
Proof. Observe that we can write A [ B as the following union of pairwise disjoint subsets: A [ B = (A \ B) [ (A B) [ (B A).
Then using the observation made just before Proposition 8.1, since we have the dis- joint unions A = (A \ B) [ (A B) and B = (A \ B) [ (B A), using the disjointness of the various subsets, we have
Pr(A [ B) = Pr(A \ B) + Pr(A B) + Pr(B A) Pr(A) = Pr(A \ B) + Pr(A B) Pr(B) = Pr(A \ B) + Pr(B A),
and from these we obtain
Pr(A [ B) = Pr(A) + Pr(B) Pr(A \ B).
The equation Pr(A) = 1 Pr(A) follows from the fact that A \ A = 0 and/ A [ A = W , so 1 = Pr(W ) = Pr(A) + Pr(A).
If A ✓ B, then A \ B = A, so B = (A \ B) [ (B A) = A [ (B A), and since A and B A are disjoint, we get
Pr(B) = Pr(A) + Pr(B A).
Since probabilities are nonegative, the above implies that Pr(A) Pr(B). ut
Remark: Proposition 8.1 still holds when W is infinite as a consequence of axioms (a)–(c) of a probability measure. Also, the equation
Pr(A [ B) = Pr(A) + Pr(B) Pr(A \ B)
can be generalized to any sequence of n events. In fact, we already showed this as the Principle of Inclusion–Exclusion, Version 2 (Theorem 6.3). The following proposition expresses a certain form of continuity of the function Pr.
Proposition 8.2. Given any probability space (W , F , Pr) (discrete or not), for any sequence of events (Ai ) (^) i 1 , if Ai ✓ Ai+ 1 for all i 1 , then
Pr
[
i= 1
A (^) i
= lim n 7 !• Pr(An ).
336 8 An Introduction to Discrete Probability
Proof. The trick is to express
S• i= 1 Ai^ as a union of pairwise disjoint events. Indeed, we have
[^ •
i= 1
Ai = A 1 [ (A 2 A 1 ) [ (A 3 A 2 ) [ · · · [ (Ai+ 1 Ai ) [ · · · ,
so by property (c) of a probability measure
Pr
[
i= 1
Ai
= Pr
[^ •
i= 1
(Ai+ 1 Ai )
= Pr(A 1 ) +
i= 1
Pr(Ai+ 1 Ai )
= Pr(A 1 ) + lim n 7 !•
n 1
i= 1
Pr(Ai+ 1 Ai )
= lim n 7 !• Pr(An ),
as claimed. ut
We leave it as an exercise to prove that if Ai+ 1 ✓ Ai for all i 1, then
Pr
i= 1
Ai
= lim n 7 !• Pr(An ).
In general, the probability Pr(A \ B) of the event A \ B cannot be expressed in a simple way in terms of Pr(A) and Pr(B). However, in many cases we observe that Pr(A \ B) = Pr(A)Pr(B). If this holds, we say that A and B are independent.
Definition 8.3. Given a discrete probability space (W , Pr), two events A and B are independent if Pr(A \ B) = Pr(A)Pr(B).
Two events are dependent if they are not independent.
For example, in the sample space of 5 coin flips, we have the events
A = {HHw | w 2 {H, T}^3 } [ {HTw | w 2 {H, T} 3 },
the event in which the first flip is H, and
B = {HHw | w 2 {H, T}^3 } [ {THw | w 2 {H,T}^3 },
the event in which the second flip is H. Since A and B contain 16 outcomes, we have
Pr(A) = Pr(B) =
The intersection of A and B is
338 8 An Introduction to Discrete Probability ✓ 365 n
n! = 365 · 364 · · · ( 365 n + 1 )
configurations where no two people have the same birthday. There are 365n^ possible choices of birthdays, so the probabilty that no two people have the same birthday is
q =
365 · 364 · · · ( 365 n + 1 ) 365 n^
n 1 365
and thus, the probability that two people have the same birthday is
p = 1 q = 1
n 1 365
In the proof of Proposition 6.15, we showed that x e x ^1 for all x 2 R, so by substituting 1 x for x we get 1 x e x^ for all x 2 R, and we can bound q as follows:
q =
n 1
i= 1
i 365
q
n 1
i= 1
e i/^365
= e ^ Â
n 1 i= 1 365 i
e ^
n(n 1 ) 2 · (^365).
If we want the probability q that no two people have the same birthday to be at most 1 /2, it suffices to require
e ^
n(n 1 ) 2 · (^365) 1 2
that is, n(n 1 )/( 2 · 365 ) ln( 1 / 2 ), which can be written as
n(n 1 ) 2 · 365 ln 2.
The roots of the quadratic equation
n^2 n 2 · 365 ln 2 = 0
are
m =
p 1 + 8 · 365 ln 2 2
and we find that the positive root is approximately m = 23. In fact, we find that if n = 23, then p = 50 .7%. If n = 30, we calculate that p ⇡ 71%. What if we want at least three people to share the same birthday? Then n = 88 does it, but this is harder to prove! See Ross [12], Section 3.4.
8.2 Conditional Probability and Independence 339
In general, the occurrence of some event B changes the probability that another event A occurs. It is then natural to consider the probability denoted Pr(A | B) that if an event B occurs, then A occurs. As in logic, if B does not occur not much can be said, so we assume that Pr(B) 6 = 0.
Definition 8.4. Given a discrete probability space (W , Pr), for any two events A and B, if Pr(B) 6 = 0, then we define the conditional probability Pr(A | B) that A occurs given that B occurs as
Pr(A | B) =
Pr(A \ B) Pr(B)
Example 8.5. Suppose we roll two fair dice. What is the conditional probability that the sum of the numbers on the dice exceeds 6, given that the first shows 3? To solve this problem, let B = {( 3 , j) | 1 j 6 }
be the event that the first dice shows 3, and
A = {(i, j) | i + j 7 , 1 i, j 6 }
be the event that the total exceeds 6. We have
A \ B = {( 3 , 4 ), ( 3 , 5 ), ( 3 , 6 )},
so we get
Pr(A | B) =
Pr(A \ B) Pr(B)
The next example is perhaps a little more surprising.
Example 8.6. A family has two children. What is the probability that both are boys, given at least one is a boy? There are four possible combinations of sexes, so the sample space is
W = {GG, GB, BG, BB},
and we assume a uniform probability measure (each outcome has probability 1/4). Introduce the events B = {GB, BG, BB}
of having at least one boy, and A = {BB}
of having two boys. We get A \ B = {BB},
and so
8.2 Conditional Probability and Independence 341
Pr(P 1; D2) = 1/ 6
Pr(P 1; D3) = 1/ 6
Pr(P 2; D3) = 1/ 3
Pr(P 3; D2) = 1/ 3
Fig. 8.3 The tree of possibilities in the Monty Hall problem.
Pr(A \C) = 1 / 6 ,
and
Pr(C) = Pr({P1; D 2 , P3; D 2 }) =
so
Pr(A | C) = Pr(A \C) Pr(C)
We also have B \C = {P3; D 2 }, so
Pr(B \C) = 1 / 3 ,
and
Pr(B | C) =
Pr(B \C) Pr(C)
Since 2/ 3 > 1 /3, the contestant has a greater chance (twice as big) to win the bigger prize by switching doors. The same probabilities are derived if the host had revealed door 3. A careful analysis showed that the contestant has a greater chance (twice as large) of winning big if she/he decides to switch doors. Most people say “on intuition” that it is preferable to stick to the original choice, because once one door is revealed, the probability that the valuable prize is behind either of two remaining doors is
342 8 An Introduction to Discrete Probability
1 /2. This is incorrect because the door the host opens depends on which door the contestant orginally chose. Let us conclude by stressing that probability trees (trees of possibilities) are very useful in analyzing problems in which sequences of choices involving various prob- abilities are made.
The next proposition shows various useful formulae due to Bayes.
Proposition 8.3. (Bayes’ Rules) For any two events A, B with Pr(A) > 0 and Pr(B) > 0 , we have the following formulae:
Pr(B | A) =
Pr(A | B)Pr(B) Pr(A)
Pr(A) = Pr(A | B)Pr(B) + Pr(A | B)Pr(B).
More generally, if B 1 ,... , Bn form a partition of W with Pr(Bi ) > 0 (n 2 ), then
Pr(A) =
n
i= 1
Pr(A | Bi )Pr(Bi ).
Pr
^ n
i= 1
Ai
= Pr(A 1 )Pr(A 2 | A 1 )Pr(A 3 | A 1 \ A 2 ) · · · Pr A (^) n |
n\ 1
i= 1
Ai
Pr(B | A) =
Pr(A | B)Pr(B) Pr(A | B)Pr(B) + Pr(A | B)Pr(B)
Proof. By definition of a conditional probability we have
Pr(A | B)Pr(B) = Pr(A \ B) = Pr(B \ A) = Pr(B | A)Pr(A),
which shows the first formula. For the second formula, observe that we have the disjoint union A = (A \ B) [ (A \ B),
so
Pr(A) = Pr(A \ B) [ Pr(A \ B) = Pr(A | B)Pr(B) [ Pr(A | B)Pr(B).
344 8 An Introduction to Discrete Probability
Pr(S) = 0. 00001 Pr(+ | S) = 0. 99 Pr(+ | S) = 0. 01.
You will find that the probability Pr(S | +) is approximately 0.000099, so the chance of being sick is rather small, and it is more likely that the test was incorrect.
Recall that in Definition 8.3, we defined two events as being independent if
Pr(A \ B) = Pr(A)Pr(B).
Asuming that Pr(A) 6 = 0 and Pr(B) 6 = 0, we have
Pr(A \ B) = Pr(A | B)Pr(B) = Pr(B | A)Pr(A),
so we get the following proposition.
Proposition 8.4. For any two events A, B such that Pr(A) 6 = 0 and Pr(B) 6 = 0 , the following statements are equivalent:
Remark: For a fixed event B with Pr(B) > 0, the function A 7! Pr(A | B) satisfies the axioms of a probability measure stated in Definition 8.2. This is shown in Ross [11] (Section 3.5), among other references.
The examples where we flip a coin n times or roll two dice n times are examples of indendent repeated trials. They suggest the following definition.
Definition 8.5. Given two discrete probability spaces (W 1 , Pr 1 ) and (W 2 , Pr 2 ), we define their product space as the probability space (W 1 ⇥ W 2 , Pr), where Pr is given by Pr(w 1 , w 2 ) = Pr 1 (w 1 )Pr 2 (W 2 ), w 1 2 W 1 , w 2 2 W 2.
There is an obvious generalization for n discrete probability spaces. In particular, for any discrete probability space (W , Pr) and any integer n 1, we define the product space (W n^ , Pr), with
Pr(w 1 ,... , wn ) = Pr(w 1 ) · · · Pr(wn ), wi 2 W , i = 1 ,... , n.
The fact that the probability measure on the product space is defined as a prod- uct of the probability measures of its components captures the independence of the trials.
Remark: The product of two probability spaces (W 1 , F 1 , Pr 1 ) and (W 2 , F 2 , Pr 2 ) can also be defined, but F 1 ⇥ F 2 is not a s -algebra in general, so some serious work needs to be done.
8.3 Random Variables and their Distributions 345
Next, we define what is perhaps the most important concept in probability: that of a random variable.
In many situations, given some probability space (W , Pr), we are more interested in the behavior of functions X : W! R defined on the sample space W than in the probability space itself. Such functions are traditionally called random variables, a somewhat unfortunate terminology since these are functions. Now, given any real number a, the inverse image of a
X ^1 (a) = {w 2 W | X(w) = a},
is a subset of W , thus an event, so we may consider the probability Pr(X ^1 (a)), denoted (somewhat improperly) by
Pr(X = a).
This function of a is of great interest, and in many cases it is the function that we wish to study. Let us give a few examples.
Example 8.9. Consider the sample space of 5 coin flips, with the uniform probability measure (every outcome has the same probability 1/32). Then the number of times X(w) that H appears in the sequence w is a random variable. We determine that
Pr(X = 0 ) =
Pr(X = 1 ) =
Pr(X = 2 ) =
Pr(X = 3 ) =
Pr(X = 4 ) =
Pr(X = 5 ) =
The function defined Y such that Y (w) = 1 iff H appears in w, and Y (w) = 0 otherwise, is a random variable. We have
Pr(Y = 0 ) =
Pr(Y = 1 ) =
Example 8.10. Let W = D ⇥ D be the sample space of dice rolls, with the uniform probability measure Pr (every outcome has the same probability 1/36). The sum S(w) of the numbers on the two dice is a random variable. For example,
S( 2 , 5 ) = 7.
The value of S is any integer between 2 and 12, and if we compute Pr(S = s) for s = 2 ,... , 12, we find the following table.
8.3 Random Variables and their Distributions 347
and the list S 2 is shown as a label on the right of node x. A leaf node is a node such that |S 1 | 1 and |S 2 | 1. If |S 1 | 2, then x has a left child, and if |S 2 | 2, then x has a right child. Let us call such a tree a computation tree. Observe that except for minor cosmetic differences, it is a binary search tree. The sorted list can be retrieved using an inorder tree traversal (left subtree, root, right subtree) of the computation tree and is ( 1 , 2 , 3 , 5 , 7 , 8 , 9 , 10 , 12 , 14 ). If you run this algorithm on a few more examples, you will realize that the choice of pivots greatly influences how many comparisons are needed. If the pivot is chosen at each step so that the size of the lists S 1 and S 2 is roughly the same, then the number of comparisons is small compared to n, in fact O(n ln n). On the other hand, with a poor choice of pivot, the number of comparisons can be as bad as n(n 1 )/2. In order to have a good “average performance,” one can randomize this algorithm by assuming that each pivot is chosen at random. What this means is that whenever it is necessary to pick a pivot from some list Y , some procedure is called and this procedure returns some element chosen at random from Y. How exactly this done is an interesting topic in itself but we will not go into this. Let us just say that the pivot can be produced by a random number generator, or by spinning a wheel containing the numbers in Y on it, or by rolling a dice with as many faces as the numbers in Y. What we do assume is that the probability measure that a number is chosen from a list Y is uniform, and that successive choices of pivots are independent. How do we model this as a probability space? Here is a way to do it. Use the computation trees defined above! Simply add to every edge the probability that one of the element of the corresponding list, say Y , was chosen uniformly, namely 1/|Y |. So given an input list S of length n, the sample space W is the set of all computation trees T with root label S. We assign a probability to the trees T in W as follows: If n = 0 , 1, then there is a single tree and its probability is 1. If n 2, for every leaf of T , multiply the probabilities along the path from the root to that leaf and then add up the probabilities assigned to these leaves. This is Pr(T ). We leave it as an exercise to prove that the sum of the probabilities of all the trees in W is equal to 1. A random variable of great interest on (W , Pr) is the number X of comparisons performed by the algorithm. To analyze the average running time of this algorithm, it is necessary to determine when the first (or the last) element of a sequence
Y = (yi ,... , y (^) j )
is chosen as a pivot. To carry out the analysis further requires the notion of expecta- tion that has not yet been defined. See Example 8.23 for a complete analysis.
Let us now give an official definition of a random variable.
Definition 8.6. Given a (finite) discrete probability space (W , Pr), a random vari- able is any function X : W! R. For any real number a 2 R, we define Pr(X = a) as the probability
348 8 An Introduction to Discrete Probability
Pr(X = a) = Pr(X ^1 (a)) = Pr({w 2 W | X(w) = a}),
and Pr(X a) as the probability
Pr(X a) = Pr(X ^1 (( •, a])) = Pr({w 2 W | X(w) a}).
The function f : R! [ 0 , 1 ] given by
f (a) = Pr(X = a), a 2 R
is the probability mass function of X, and the function F : R! [ 0 , 1 ] given by
F(a) = Pr(X a), a 2 R
is the cumulative distribution function of X.
The term probability mass function is abbreviated as p.m.f , and cumulative dis- tribution function is abbreviated as c.d.f. It is unfortunate and confusing that both the probability mass function and the cumulative distribution function are often ab- breviated as distribution function. The probability mass function f for the sum S of the numbers on two dice from Example 8.10 is shown in Figure 8.5, and the corresponding cumulative distribution function F is shown in Figure 8.6.
Fig. 8.5 The probability mass function for the sum of the numbers on two dice.
If W is finite, then f only takes finitely many nonzero values; it is very discontin- uous! The c.d.f F of S shown in Figure 8.6 has jumps (steps). Observe that the size of the jump at every value a is equal to f (a) = Pr(S = a). The cumulative distribution function F has the following properties: