Probability and Statistics Course Guide
Probability and Statistics Course Guide
Almut E. D. Veraart
Room 551, Huxley Building
Department of Mathematics
Imperial College London
180 Queen’s Gate, London, SW7 2AZ
E-Mail: [Link]@[Link]
Autumn 2023
1
Contents
1 Introduction 4
1.1 Why do we study probability? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Complementary reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Course overview (Autumn term) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Counting 14
3.1 The multiplication principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Power sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 Sampling with and without replacement . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3.1 Sampling with replacement – ordered . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3.2 Sampling without replacement – ordered . . . . . . . . . . . . . . . . . . . . . . 16
3.3.3 The birthday problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3.4 Sampling without replacement – unordered . . . . . . . . . . . . . . . . . . . . . 18
3.3.5 Sampling with replacement – unordered . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.6 Summary table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5 Conditional probabilities 28
5.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.3 Multiplication rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.4 Bayes’ rule and law of total probability . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.4.1 Bayes’ rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.4.2 Law of total probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.4.3 General Bayes’ rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.4.4 Bayes’ rule and law of total probability with additional conditioning . . . . . . . . 31
1
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
5.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.5.1 Examples: Cards and marbles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.5.2 Example: Testing for a rare disease . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.5.3 Example: Monty Hall – Conditioning on the missing information . . . . . . . . . 35
6 Independence 37
6.1 Independence of events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.1.1 Conditional independence of events . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.1.2 Continuity of the probability measure and product rule . . . . . . . . . . . . . . . 39
2
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
13 Generating functions 87
13.1 Probability generating functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.1.1 Common probability generating functions . . . . . . . . . . . . . . . . . . . . . . 88
13.1.2 Probability generating function of a sum of independent discrete random variables 89
13.1.3 Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.2 Moment generating functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.2.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
13.3 Using m.g.f.s for finding all moments of the exponential and the standard normal distributions 93
13.4 Outlook: Characteristic function and Laplace transform . . . . . . . . . . . . . . . . . . . 93
3
Chapter 1
Introduction
• is a beautiful branch of mathematics with a long history going back to the early works by Cardano
(16th century), Fermat and Pascal (17th century), Laplace (19th century). Modern (axiomatic) prob-
ability theory, however, is a much younger discipline which goes back to the influential work by
Kolmogorov published in 1933,
• is a very dynamic discipline with a strong interplay between theory and applications,
• is ubiquitous in every day life and in most sciences,
• is the foundation for statistics,
• enables us to interpret and quantify uncertainty.
• Complementary reading material can be found in the following textbooks: Ross (2014).
4
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
5. Multivariate random variables: Joint mass and density functions; independence; covariance
6. Conditional distribution: Conditional probability mass function, conditional density, conditional ex-
pectation, law of total expectation
5
Chapter 2
The material of this chapter is based on Blitzstein & Hwang (2019), p.1-8, Anderson et al. (2018), p.1-5,
Proschan & Shaw (2016), p.9-10.
2.1 Notation
Throughout the lecture notes we denote the natural numbers by N = {1, 2, . . . } and we define N0 =
N ∪ {0}. Moreover, we denote the integers by Z = {. . . , −1, 0, 1, . . . }, the real numbers by R. For real
numbers a < b we write [a, b] for closed intervals and (a, b) for open intervals.
Example 2.2.2. We start with the classical example of flipping a (fair) coin. We write H for heads and T
for tails. The sample space is given by
Ω = {H, T }.
6
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 2.2.3. Consider the experiment where we roll a standard six-sided (fair) die. The sample space
associated with this experiment is given by
Ω = {1, 2, 3, 4, 5, 6}.
• Subsets of Ω are collections of elements of Ω and called events. Notation: A is a subset of Ω can be
written as A ⊆ Ω meaning that every element of A is also an element of Ω.
• We write ω ∈ A if the element ω is a member of A and ω ̸∈ A if the element ω is not a member of
A.
• We denote the empty set by ∅. Note that the empty set contains no points, i.e. ω ̸∈ ∅ for all ω ∈ Ω.
Example 2.2.4. Let Ω = {1, 2, 3, 4, 5, 6}. For instance, we can say that 1 ∈ Ω and {1} ⊆ Ω.
Suppose that A, B ⊆ Ω are events, then
• the union A ∪ B = {ω ∈ Ω : ω ∈ A or ω ∈ B} is the event that at least one of A and B occurs (this
is the inclusive ”or”),
7
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Ω Ω
B B
A A A∪B
(a) A, B ⊆ Ω (b) A ∪ B
Ω Ω
B B
A∩B
A A
Ac
(c) A ∩ B (d) Ac
Figure 2.2: We consider a sample space Ω with subsets A, B ⊆ Ω which are depicted in Figure 2.2a. The
grey area in Figure 2.2b depicts the union A ∪ B. The grey area in Figure 2.2c depicts the intersection
A ∪ B, and the grey area in Figure 2.2d depicts the complement Ac .
In MATH40001 you studied De Morgan’s laws and distributivity for propositions. These results imply
the following very useful identities for sets.
Let I denote a general index set, e.g. I = {1, 2} or I = N or I = [0, ∞). Suppose that Ai ⊆ Ω for all
i ∈ I and B ⊆ Ω. Then the following identities hold.
• De Morgan’s laws:
!c !c
\ [ [ \
Ai = Aci , and Ai = Aci ,
i∈I i∈I i∈I i∈I
• Distributivity:
! !
[ [ \ \
B∩ Ai = (B ∩ Ai ), and B∪ Ai = (B ∪ Ai ).
i∈I i∈I i∈I i∈I
Let us prove the first De Morgan’s law as an exercise. First we consider the easier case when I = {1, 2}.
c
Exercise 2.2.5. Using the notation above, show that (A1 ∩ A2 ) = Ac1 ∪ Ac2 .
Proof. Here we want to prove an identity between two sets. As a general strategy, recall that we can prove
the equality by first showing that the set on the left hand side is a subset of the set on the right hand side
and then that the set on the right hand side is a subset of the set on the left hand side.
Proof of (A1 ∩ A2 )c ⊆ Ac1 ∪ Ac2 :
Let a ∈ (A1 ∩ A2 )c .
⇒ Then a is not an element of (A1 ∩ A2 ).
8
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
End of lecture 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.2 Cardinality
Definition 2.2.7 (Cardinality). For any set A, we define the cardinality of A as the number of elements in
A. We typically write card(A) or simply |A| (the latter should not be confused with the absolute value!).
Example 2.2.8. Let us compute the cardinality of the sample spaces Ω considered in the two examples
above.
• Flipping of a (fair) coin. Here we have Ω = {H, T }, then
card(A) = 2.
card(A) = 6.
Definition 2.2.9. Two sets have the same cardinality if there is a bijection between the two sets.
Bijective functions were introduced in MATH40001. Let us recall their definition again.
Definition 2.2.10 (Injective, surjective and bijective functions).
• A function f : A 7→ B is called injective if ∀a1 , a2 ∈ A, f (a1 ) = f (a2 ) ⇒ a1 = a2 .
9
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Next, we show that f is surjective. For all y ∈ Z, y < 0, choose x = −2y − 1 (which is odd), then
f (x) = − −2y−1+1
2 = y. For all y ∈ Z, y ≥ 0, choose x = 2y (which is even), then f (x) = 2y
2 = y.
card(A)
PNaive (A) = .
card(Ω)
10
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
In addition to the assumption that the sample space is finite, the naive definition of a probability also
assumes that each possible outcome has the same weight. When is such a definition applicable? In sym-
metric settings when all outcomes are equally likely (for instance when we toss a fair coin or roll a fair
die), or in settings where the outcomes are equally likely due to the design of a study (for instance when
I randomly select 10 students out of the entire year group assuming that the selection mechanism is such
that all subsets of 10 students are equally likely).
Example 2.3.2. Consider the example of rolling a six-sided fair die. What is the (naive) probability that I
roll either a 1 or a 2? We have Ω = {1, . . . , 6} and A = {1, 2}. Hence
card(A) 2 1
PNaive (A) = = = .
card(Ω) 6 3
Let us consider the complement: Ac = {3, 4, 5, 6}. The probability of the complement can be computed as
Note that for A ⊆ Ω we always have that P(Ac ) = 1 − P(A), not just in the case of the naive
probability.
The classical interpretation applies when we have outcomes that are equally likely. In our naive defini-
tion above, we have only covered the case when card(Ω) < ∞. If Ω is uncountably infinite, but of finite
area, e.g. choose a disk of radius 1: Ω = {(x, y) ∈ R2 : x2 + y 2 ≤ 1} and the event A is some subset of
Ω, then we could assume that the probability of the event A should be uniform on Ω, i.e.
area of A
P(A) = .
area of Ω
For instance, for A = {(x, y) ∈ R2 : x2 + y 2 ≤ 0.52 }, we have
area of A 0.52 π
P(A) = = = 0.25.
area of Ω π
A x
−1 1
−1
Figure 2.3: Illustration of the classical interpretation of probability in the case when Ω is uncountably
infinite.
Remark 2.3.3. In order for the classical/naive definition to work, we need that the number of elements
in Ω is either finite, or, if Ω is uncountably infinite, then we require that the area of Ω is finite. In either
scenario we can then define a uniform distribution, which we will study in more detail later in the course.
Note that there is no uniform distribution on N or on R.
11
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 2.3.4. Consider a fair coin toss and let A = {H} denote the event that Heads appears. Figure1
2.4 illustrates a possible outcome of the experiment.
Figure 2.4: One possible outcome when tossing a fair coin repeatedly.
Let us compute the relative frequency of A and report and plot them in Table 2.1 and Figure 2.5,
respectively.
ntotal 1 2 3 4 5 6 7 8 9 10 ···
nA
ntotal 0/1 0/2 1/3 2/4 2/5 3/6 4/7 5/8 6/9 6/10 ···
Table 2.1: Relative frequencies of heads when repeatedly tossing a fair coin.
1 The pictures of the one pound coin are attributed to Sir Magnus Fluffbrains [CC BY-SA 4.0
([Link] [Link]
[Link] and [Link]
12
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
0.6
0.6
Relative frequency nA ntotal
0.5
0.4
0.4
0.3
0.3
0.2
0.2
0.1
0.1
0.0
0.0
0 20 40 60 80 100 0 1000 2000 3000 4000 5000
Figure 2.5: Relative frequencies of heads when repeatedly tossing a fair coin.
2.3.3 Subjective
For an event A, we can assign the probability P(A) according to our personal “degree of belief”. This
could be done according to historical information or local knowledge. This probability will not need to be
the same for each individual. The subjective approach may be difficult to implement in practice, but is a
valid and universal interpretation of probability.
Remark 2.3.5. It is important to remember that all three interpretations of probability depend on assump-
tions about experimental conditions.
13
Chapter 3
Counting
The material of this chapter is based on Blitzstein & Hwang (2019), p.8-28, Anderson et al. (2018),
p.4-11.
In order to compute (naive) probabilities we need to be able to count events in possibly large (but fi-
nite) sample spaces. The area of mathematics which deals with counting is called Combinatorics. We will
study some key ideas from combinatorics and show their interplay with probability theory.
We illustrate the proof of the multiplication principle in Figure 3.1 in the case when the outcomes
of Experiment A are labelled as A1 , A2 (for a = 2) and the outcomes of Experiment B are labelled as
B1 , B2 , B3 (for b = 3).
A1 A2
B1 B2 B3 B1 B2 B3
Figure 3.1: Illustration of the proof of the multiplication principle in the case when the outcomes of Exper-
iment A are labelled as A1 , A2 (for a = 2) and the outcomes of Experiment B are labelled as B1 , B2 , B3
(for b = 3).
14
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Exercise 3.1.2. We flip a fair coin three times. We write ”0” for heads and ”1” for tails. Find the sample
space Ω and PNaive ({ω}) for all ω ∈ Ω. Also, compute the probability that the first and the third flip are
tails.
Proof. Here the sample space is given by
which are all the ordered triplets of zeros and ones. By the multiplication principle we have that card(Ω) =
23 = 8, hence PNaive ({ω}) = 1/8 for all ω ∈ Ω.
Let us now consider the event B := the first and the third flip are tails = {(1, 0, 1), (1, 1, 1)}. Then
PNaive (B) = 2/8 = 1/4.
Remark 3.1.3. If we deal with repetitions of experiments (coin toss, rolling a die), the corresponding
sample spaces are given by Cartesian product spaces.
For sets A1 , . . . , An , we define the Cartesian product as
So in our example above, we can write Ω = {0, 1} × {0, 1} × {0, 1} = {0, 1}3 .
End of lecture 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Definition 3.2.2 (Power set). A power set of a set A, denoted as P(A) is defined as the set of all possible
subsets of A including ∅ and A.
Proof. From the theorem above, we know that the corresponding power set P(Ω) consists of card(P(Ω)) =
23 = 8 elements. Also, we have
P(Ω) = {∅, {A}, {B}, {C}, {A, B}, {A, C}, {B, C}, Ω}.
15
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Figure 3.2: Consider an urn with n ∈ N balls which are labelled {1, . . . , n}. How many possible ways are
there to draw k ∈ N balls with or without replacement?
Theorem 3.3.1 (Sampling with replacement). In the case of sampling k balls with replacement from an
urn containing n balls as described above, there are card(Ω) = nk possible outcomes when the order of
the objects matters.
Proof. The result is a direct consequence of the multiplication principle: Each time we draw a ball, there
are n possible outcomes. We carry out this experiment k times, so there are nk ways of obtaining a sample
consisting of k balls.
Theorem 3.3.2 (Sampling without replacement). In the case of sampling k balls without replacement from
an urn containing n balls as described above, there are card(Ω) = n(n − 1) · · · (n − (k − 1)) = (n)k
possible outcomes when the order of the objects matters.
16
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Definition 3.3.3 (Factorial). Let n ∈ N. The factorial of n, denoted by n!, is defined asQ the product of all
n
natural numbers less than or equal to n, i.e. n! = n · (n − 1) · (n − 2) · · · 3 · 2 · 1 = i=1 i. We define
0! = 1.
Definition 3.3.4 (Descending factorial). For k, n ∈ N with k ≤ n, we define the descending factorial,
Qk−1 Qn
denoted by (n)k as (n)k = n(n − 1) · · · (n − k + 1) = i=0 (n − i) = j=n−k+1 j with the convention
n!
that (n)1 = n. We note that the descending factorial can be expressed as (n)k = (n−k)! .
The factorial arises naturally in the context of so-called permutations. Consider the set of numbers
{1, 2, . . . , n}. A permutation brings these numbers into a certain order. As a consequence of Theorem
3.3.2 with k = n, we deduce that the numbers in the set {1, 2, . . . , n} can be arranged in exactly n!
possible ways.
Example 3.3.5. Consider the set {1, 2, 3}. How many permutations (i.e. possible orderings) are there? We
can write (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1), so we have 3! = 6 possible permutations.
• Due to our assumption, the naive probability definition is applicable here. First we count how many
possible ways there are to assign birthdays to the k people in the room.
• This problem can be viewed as sampling with replacement, so we have 365k possible birthday com-
binations.
• Next, we need to count how many scenarios there are such that at least two people have the same
birthday. It appears that this is rather challenging...
• What is easier to compute is the complement, i.e. the number of scenarios such that no two people
share the same birthday. This number can be computed using sampling without replacement, which
leads to (365)k possible outcomes.
PNaive (At least two people in the room have the same birthday)
= 1 − PNaive (All people in the room have distinct birthdays)
(365)k 365 364 365 − (k − 1)
=1− =1− ··· =: f (k).
365k 365 365 365
17
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
1.0
Probability of birthday match
0.8
0.6
0.4
0.2
0.0
0 20 40 60 80 100
k
Figure 3.3: We compute the probability f (k) that, out of k people in a room, at least two share the same
birthday.
We plot the probabilities f (k) for k = 1, . . . , 100 in Figure 3.3. Note that f (22) ≈ 0.476 and f (23) ≈
0.507, so you need to have at least 23 people in the room to have a probability of at least 50% such that at
least two people share the same birthday.
Exercise 3.3.7. A college has 10 non-overlapping time slots for its courses and assigns courses to time
slots randomly and independently. A student randomly chooses three of the courses to enroll in. What is
the probability that there is a conflict in the student’s schedule?
Proof. Using the multiplication principle and the naive probability, we can compute the probability of no
schedule conflict as 10·9·8
103 (= 0.72). So the probability that there is at least one schedule conflict is given
by 1 − 10·9·8
10 3 (= 0.28).
Exercise 3.3.8. A fair die is rolled 6 times. What is the probability that some value is repeated?
Proof. There are 66 possible outcomes when rolling a die 6 times. There are 6! configurations where each
number appears exactly once. Hence P(no value repeated) = 66!6 and P(at least one value is repeated) =
1 − 66!6 (≈ 0.9845).
End of lecture 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
The theorem can be proven as follows: We expand (x + y)n = (x + y) · · · (x + y) in n factors and then
pick either the x or the
y from the first factor, multiply this to either the x or the y of the second factor and
so on. There are nk ways of picking exactly k x’s and each of these choices leads to a term of the form
xk y n−k . Summing over all possible k leads the result.
Exercise 3.3.12. A family has 6 children consisting of 3 boys and 3 girls. Assuming that all birth orders
are equally likely, what is the probability that the 3 eldest children are the 3 girls?
Proof. Label the girls as 1, 2, 3, and the boys as 4, 5, 6. Then the birth order is a permutation of 1, 2, 3, 4,
5, 6. So, 236514 means that child 2 was born first, then child 3 etc. The number of possible permutations is
6!. For the three girls to be the eldest children, we need a permutation of 1,2,3, followed by a permutation
of 4,5,6. Hence
3!3! 1
P(the 3 girls are the 3 eldest children) = = = 0.05.
6! 20
Alternative proof: There are 63 ways to chose where the three girls appear in the birth order (without
taking ordering of the girls into account). Of these cases, there is only one where the three girls are the
three eldest children. Hence
1 3!3! 1
P(the 3 girls are the 3 eldest children) =
6 = 6! = 20 = 0.05.
3
2. How many ways are there to break the people into two teams of two?
Proof. Part 1: We use two approaches to show that there are 6 possibilities:
• We could list all possibilities: Label the people as 1, 2, 3, 4. Then the possibilities are
{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4},
19
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
• Alternatively, we can use the multiplication rule and account for overcounting:
There are 4 possibilities for choosing the first person on the committee and 3 to choose the second
person. Note, however, that this counts every possibility twice since picking 1 and 2 is the same as
picking 2 and 1. We have overcounted by a factor of 2. So the number of possibilities is given by
4·3 4
=6 = .
2 2
{1, 2}, {3, 4}; {1, 3}, {2, 4}; {1, 4}, {2, 3},
Exercise 3.3.14. How many ways are there to permute the letters in the word STATISTICS? Note that there
are 10 letter in total, ”S” and ”T” appear three times, ”I” twice and ”A” and ”C” once.
Proof. • Approach 1: There are 10 positions in total, first we choose the 3 positions for the ”S”s out
of 10, then the 3 positions for the ”T”s out of the remaining 7 positions etc. Hence we get
= 50400
10 7 4 3 1
3 3 1 2 1
| {z } |{z} |{z} |{z} |{z}
”S” ”T ” ”A” ”I” ”C”
• Approach 2: Start with 10! permutations of the 10 letters and adjust for overcounting:
10!
= 50400.
3!3!2!
20
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Proof. Consider n distinguishable boxes representing the n distinct labels of the balls in the urn. We
can draw these n boxes using n + 1 bars which represent the walls of the boxes, see Figure 3.4 for an
illustration. Next, we have k indistinguishable balls, which we now draw as stars and place them into the
boxes, i.e. between the bars.
Figure 3.4:
Illustration
of the stars and bars method in the case when n = 6 and k = 10. Here we have
n+k−1 15
k = 10 = 3003 possible outcomes.
I.e. we can view the stars as “check marks” which count how often a particular label gets selected.
Between the two outer walls (i.e. the first and the last bar), which are fixed, there are n − 1 bars and k stars,
i.e. n + k − 1 symbols which can be arranged in any possible order. Out of the n + k − 1 possible positions,
we choose k positions for the stars and fill the remaining positions with bars. Hence card(Ω) = n+k−1 k .
Note that we could have picked the n − 1 bars instead and then filled in the remaining stars, which leads to
the identity
n+k−1 n+k−1
card(Ω) = = .
k n−1
It is important to remember that you should not use the above result in connection with the naive
probability since the unordered samples are typically not equally likely.
Exercise 3.3.16. [Exam question 2020] How many possibilities are there to write the number 7 as an
ordered sum of 3 positive integers? [E.g. 7=1+3+3 would be one possible case and 7=3+1+3 would be
another case.]
Proof. We present an elementary solution here: We can write down all possible 3-tuples of numbers which
sum up to 7:
• (1, 3, 3) with 3!/2! = 3 possible arrangements (where we adjusted for over-counting since the num-
ber 3 appears twice),
Hence there are 3 + 3 + 3 + 6 = 15 possibilities of writing the number 7 as a sum of 3 positive integers.
Exercise 3.3.17. [Exam question 2020] Let k, n ∈ N = {1, 2, . . .}. How many possibilities are there to
write the number k as an ordered sum of n positive integers?
21
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Proof. We can use a stars and bars argument: There are 0 possibilities if k < n.
Now suppose that k ≥ n. Then we represent the number k as k stars which we would like to place
in n bins such that each bin contains at least one object (since we have the restriction that all addends are
positive integers). We can first write the k stars in one line. Then there are k − 1 possible gaps between
the stars, where a bar could be inserted to separatethe bins. We need to select n − 1 gaps out of the k − 1
k−1
gaps, to create the n bins, so in total we have n−1 possibilities.
The above proof can be further illustrated by associating the stars with ”1”s and then writing
k = 1 + 1 + 1 + · · · + 1,
i.e. we express k as a sum of k ”1”s. Each ”+” sign is a possible location for a bar. There are k − 1 ”+”signs
and we need to choose n − 1 of them which leads to the result.
For instance, in the case of Exercise 3.3.16, one possible configuration is ∗| ∗ ∗ ∗ | ∗ ∗∗, where we have
1 star in the first bin, followed by 3 stars in the next bin, followed by 3 stars in the last bin. This can be
viewed is writing
7 = 1 + (1 + 1 + 1) + (1 + 1 + 1).
Ordered Unordered
n+k−1
With replacement nk k
Without replacement
n
(for k ≤ n only) (n)k k
End of lecture 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
Chapter 4
The material of this chapter is based on Blitzstein & Hwang (2019), p.21-26, Anderson et al. (2018),
p.1-21, Grimmett & Welsh (1986), p.3-9.
In this chapter we will focus on an axiomatic definition of probability and derive some of the key
properties of the probability measure.
(a) ∅ ∈ F,
(b) F is closed under complements, i.e. A ∈ F ⇒ Ac ∈ F, and
(c) F is closed under unions of pairs of members, i.e. A1 , A2 ∈ F ⇒ A1 ∪ A2 ∈ F.
2. an σ-algebra (or a σ-field) on Ω if
(a) ∅ ∈ F,
(b) F is closed under complements, i.e. A ∈ F ⇒ Ac ∈ F, and
(c) F is closed under countable union, i.e. for any countable 1 index set I, we have Ai ∈ F, for
all i ∈ I ⇒ ∪i∈I Ai ∈ F.
23
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
These results can be further extended to the corresponding finite disjoint unions of sets specified
above and imply that for any A ∈ F, we also have that Ac ∈ F.
3. The closedness under unions of pairs follows directly from the definition of F.
Hence F is an algebra.
However, it is NOT a σ-algebra. To see this, note that
1
Ai = 0, 1 − ∈ F,
i
but
∞
[
1 1 1
Ai = 0, 1 − ∪ 0, 1 − ∪ 0, 1 − ∪ · · · = (0, 1) ̸∈ F.
i=1
1 2 3
1. ∅ ∈ F since it is finite,
2. For any A ∈ F, we have either
or
Ac is finite ⇒ Ac ∈ F.
or at least one Aci is finite for i = 1, 2. Without loss of generality assume that Ac2 is finite. Then, by
De Morgan’s law,
Hence F is an algebra.
However, F is NOT a σ-algebra. To see this, note that
Ai = {i} ∈ F since it is finite, but ∪∞ c
i=1 Ai = N ̸∈ F since it is not finite and N = R \ N is not finite
either!
Note that if we work with Ω = N instead in the above example, we still get that F is an algebra, but not
a σ-algebra. Here we could take Ai = {2i}, the ∪∞ i=1 Ai are the even natural numbers, which are infinite,
and (∪∞ c ∞
i=1 Ai ) are the odd natural numbers, which are infinite, too. So ∪i=1 Ai ̸∈ F.
Remark 4.1.4. 1. Any algebra is closed under finite unions and finite intersections.
24
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 4.1.5. Consider any sample space Ω. Then the so-called trivial σ-algebra is defined as Ftrivial =
{∅, Ω} and the total or power σ-field is defined as F = P(Ω) = {all subsets of Ω}.
Example 4.1.6. Consider a sample space Ω with A ⊆ Ω. Then {∅, Ω, A, Ac } is a σ-algebra (in fact the
smallest σ-algebra including A).
Throughout the course, we shall assume that F is a σ-algebra. This will allow us to consider countable
infinite rather than finite unions. Note that this is clearly more restrictive than assuming that F is an algebra.
So why do we care about algebras at all? In probability we typically define a probability measure first
on an algebra and extend it to a σ-algebra. The details behind this construction are beyond the scope of this
introductory course, but you can learn more about this in our measure theory course.
(ii) P(Ω) = 1,
(iii) For any countable2 sequence of disjoint events (Ai )i∈I with Ai ∈ F, for all i ∈ I, we have
!
[ X
P Ai = P(Ai ).
i∈I i∈I
25
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Using the fact that the probability measure is nonnegative (axiom (i)), we conclude that P(B ∩Ac ) ≥
0 and hence
3. Show P(A ∪ B) = P(A) + P(B) − P(A ∩ B): We express A and B in terms of disjoint unions:
A = (A ∩ B) ∪ (A ∩ B c ), B = (B ∩ A) ∪ (B ∩ Ac ).
Hence
A ∪ B = (A ∩ B) ∪ (A ∩ B c ) ∪ (B ∩ Ac ).
So, indeed,
Some graphical illustrations for the arguments presented in the above proof are given in Figure 4.1.
Ω Ω
B B
A∩B B ∩ Ac A ∩ Bc A∩B B ∩ Ac
A A
(a) (b)
Figure 4.1: We consider a sample space Ω with subsets A, B ⊆ Ω. Figures 4.1a and 4.1b depict the settings
we are considering in the proofs of Theorem 4.2.3 part 2 and 3, respectively.
End of lecture 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Remark 4.2.4. The above theorem implies that P(∅) = 0. To see this, note that Ω and ∅ are disjoint since
Ω ∩ ∅ = ∅. Also, Ω = Ω ∪ ∅. So, altogether we have 1 = P(Ω) = P(Ω ∪ ∅) = P(Ω) + P(∅) = 1 + P(∅).
Hence, P(∅) = 0.
26
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
4.2.3 Examples
Example 4.2.5. We continue with the classical example of flipping a fair coin.
We write H for heads and T for tail. The sample space is given by Ω = {H, T }. The event space can be
taken as F = {∅, {H}, {T }, Ω} which is the collection of all subsets of Ω. Since we are considering a
”fair” coin, we have that P({H}) = P({T }) = 21 , where we typically shorten the notation to:
1
P(H) = P(T ) = .
2
Moreover, we have P(∅) = 0 and P(Ω) = 1.
P e−λ λx
Exercise 4.2.6. Let Ω = N ∪ {0}, F = P(N ∪ {0}), P : F → R with P(A) = x∈A x! for λ > 0.
Show that (Ω, F, P) is a probability space.
Proof. We know from lectures that the power set is a σ-algebra. So we only need to show that P is a
probability measure. We note that P : F → R and hence it remains to check the three axioms of the
definition of a probability measure:
P∞ x
Axiom (ii) We use the fact that x=0 λx! = eλ , to deduce that
∞
X λx
P(Ω) = e−λ = eλ e−λ = 1.
x=0
x!
X λx X∞
λx −λ
0 ≤ P(A) = e−λ ≤ e = 1.
x! x=0
x!
x∈A
27
Chapter 5
Conditional probabilities
The material of this chapter is based on Blitzstein & Hwang (2019), p.45-63, Anderson et al. (2018),
p.43-56, Grimmett & Welsh (1986), p.11-12.
After having introduced the axiomatic definition of a probability measure, we will now turn our atten-
tion to so-called conditional probabilities. We will learn how probabilities can be computed based on some
given evidence. Conditional probabilities play a key role in almost all subsequent probability and statistics
course und you will learn that they constitute a powerful concept for computing unconditional probabilities
as well.
5.1 Definition
Definition 5.1.1 (Conditional probability). Consider a probability space (Ω, F, P). Consider events A, B ∈
F with P(B) > 0. Then the conditional probability of A given B, denoted by P(A|B), is defined as
P(A ∩ B)
P(A|B) = .
P(B)
Remark 5.1.2. Interpretation: You could call P(A) the prior probability of event A and P(A|B) the
posterior probability of A. Here we view B as additional evidence which becomes available, and the
prior probability is formulated without knowledge of the additional evidence and the posterior probability
describes the updated probability based on the additional evidence.
Let us now show that the conditional probability measure does indeed satisfy the axioms of a probability
measure:
Theorem 5.1.3 (Conditional probability). Let B ∈ F with P(B) > 0 and define Q : F → R by Q(A) =
P(A|B). Then (Ω, F, Q) is a probability space.
Proof. The only thing we need to show is that Q satisfies the axioms of a probability measure on (Ω, F).
Axiom (i): Since P is a probability measure satisfying axiom (i), we deduce that, for any A ∈ F,
P(A ∩ B)
Q(A) = ≥ 0.
P(B)
Axiom (ii):
P(Ω ∩ B) P(B)
Q(Ω) = = = 1.
P(B) P(B)
Axiom (iii): Consider disjoint events Ai ∈ F for i ∈ I. Then
! S S P
[ P i∈I Ai ∩ B P ∈I (Ai ∩ B) P(Ai ∩ B)
Q Ai = = = i∈I
P(B) P(B) P(B)
i∈I
28
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
X P(Ai ∩ B) X
= = Q(Ai ),
P(B)
i∈I i∈I
where for the third equality we used the fact that the events Ai ∩ B ∈ F are disjoint and that P satisfies
axiom (iii).
5.2 Examples
Example 5.2.1. We roll a single fair die. Hence Ω = {1, 2, 3, 4, 5, 6}. What is the probability that the
score is greater than 3 given that the score is even? We define the events
Then, A ∩ B = {4, 6}. We have P(A) = 1/2, P(B) = 1/2 and P(A ∩ B) = 2/6 = 1/3.
P(A ∩ B) 1/3 2
P(A|B) = = = .
P(B) 1/2 3
Example 5.2.2. A family has two children. Assume that Female (F)/Male (M) are equally likely and
successive births are independent. We write Ω = {F F, F M, M F, M M }, where e.g. F M stands for the
event that the first child is Female and the second child is Male. Note that all four outcomes are equally
likely, so P(ω) = 1/4 for all ω ∈ Ω.
1. If one child is a boy, what is the probability that both children are boys?
2. If the eldest is a boy, what is the probability that both children are boys?
Let A = {M M } both male, B = {M M, M F, F M } at least one male, C = {M M, M F } eldest is male.
Then
P(A ∩ B) 1/4 1
P(A|B) = = = ,
P(B) 3/4 3
and
P(A ∩ C) 1/4 1
P(A|C) = = = .
P(C) 2/4 2
Remark 5.2.3. Consider the case of a finite state space Ω where all events are equally likely and hence
the classical interpretation of probability can be used. Then for two events A, B ⊆ Ω, we have that
card(A∩B)
card(A ∩ B) card(Ω) P(A ∩ B)
P(A|B) = = card(B)
= .
card(B) P(B)
card(Ω)
P(A ∩ B)
P(A|B) = ⇔ P(A ∩ B) = P(A|B)P(B).
P(B)
29
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Similarly,
P(A ∩ B)
P(B|A) = ⇔ P(A ∩ B) = P(B|A)P(A).
P(A)
Let us extend the above result to three events: Let C ∈ F with P(C) > 0. Then
P(B|A)P(A)
P(A|B) =
P(B)
Proof. This is an immediate consequence of the definition of conditional probability and the multiplication
rule.
Definition 5.4.2 (Partition). A partition of the sample space Ω is a collection {Bi : i ∈ I} (for a S
countable
index set I) of disjoint events (meaning that Bi ∈ F and Bi ∩ Bj = ∅ for i ̸= j) such that Ω = i∈I Bi .
Remark 5.4.3. We note that a partition of the sample space is often not unique and the choice of the
particular partition typically very much depends on the problem we want to solve!
Theorem 5.4.4 (Law of total probability). Let {Bi : i ∈ I} denote a partition of Ω, with P(Bi ) > 0 for
all i ∈ I. Then, for all A ∈ F,
X X
P(A) = P(A ∩ Bi ) = P(A|Bi )P(Bi ).
i∈I i∈I
30
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Proof. Using the properties of a partition and the distributivity property, we deduce that
!
[ [
A=A∩Ω=A∩ Bi = (A ∩ Bi ),
i∈I i∈I
where the events A ∩ Bi are disjoint. Using axiom (iii) of the definition of the probability measure leads to
X
P(A) = P(A ∩ Bi ),
i∈I
A ∩ B1 A ∩ B2 A ∩ B3
A A ∩ B4
B1 B2 B3 B4
P4
Figure 5.1: Illustration of the law of total probability. Here we have that P(A) = i=1 P(A ∩ Bi ).
Theorem 5.4.5. Consider a partition {Bi : i ∈ I} of Ω with P(Bi ) > 0 for all i ∈ I, then for any event
A ∈ F with P(A) > 0, we have
5.4.4 Bayes’ rule and law of total probability with additional conditioning
The Bayes’ rule and the law of total probability also hold with extra conditioning.
Theorem 5.4.6 ( Bayes’ rule with extra conditioning). For events A, B, E with P(A∩E) > 0, P(B ∩E) >
0, we have
P(B|A ∩ E)P(A|E)
P(A|B ∩ E) = .
P(B|E)
31
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Theorem 5.4.7 (Law of total probability with additional conditioning). Consider events A, E with P(E) >
0 and let {Bi : i ∈ I} denote a partition of Ω, with P(Bi ∩ E) > 0 for all i ∈ I. Then,
X P(A ∩ Bi ∩ E) X
P(A|E) = = P(A|Bi ∩ E)P(Bi |E).
P(E)
i∈I i∈I
5.5 Examples
5.5.1 Examples: Cards and marbles
Example 5.5.1. We pick 2 cards at random from a well-shuffled 52-card deck. We consider the event
E:=”2nd card is red”. What is P(E)?
We use the law of total probability to deduce that
P(E) = P(E| 1st card red)P(1st card red) + P(E|1st card black)P(1st card black)
25 1 26 1 1
= · + · = .
51 2 51 2 2
Example 5.5.2. You have three bags that each contain 100 marbles. Bag 1 has 70 red and 30 green
marbles. Bag 2 has 60 red and 40 green marbles. Bag 3 has 50 red and 50 green marbles. 1) If you choose
one bag at random and then pick a marble at random from the chosen bag. What is the probability that the
chosen marble is red? 2) Suppose that the chosen marble was red, what is the probability that bag 1 was
chosen?
1. We define the events Bi :=bag i was chosen, P(Bi ) = 31 , i = 1, 2, 3. R := marble is red. Then
7 6 5
P(R|B1 ) = , P(R|B2 ) = , P(R|B3 ) = ,
10 10 10
We use the law of total probability:
7 6 5 1
P(R) = P(R|B1 )P(B1 ) + P(R|B2 )P(B2 ) + P(R|B3 )P(B3 ) = + + = 0.6.
10 10 10 3
32
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
33
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Figure 5.2: Visualising conditional probabilities in the case of testing for a rare disease. This picture is a
copy of Figure 4 in the article Spiegelhalter et al. (2011).
34
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Label the doors 1, 2 and 3 and assume without loss of generality that the candidate selects door 1. Monty
Hall then opens a door and reveals a goat. When deciding whether or not to switch, which information
would the contestant like to have? She would like to know the location of the car.
So let us consider the partition: {Ci , i = 1, 2, 3} where Ci is the event that the car is behind the ith
door (for i = 1, 2, 3). Also, we denote by H2 the event that Monty Hall opens door 2. Then P(C1 ) =
P(C2 ) = P(C3 ) = 1/3 and P(H2 |C1 ) = 1/2, P(H2 |C2 ) = 0 and P(H2 |C3 ) = 1. We want to compare
the probabilities of P(C1 |H2 ) (STICK) with P(C3 |H2 ) (SWITCH). Using the law of total probability, we
have
P(H2 ) = P(H2 |C1 )P(C1 ) + P(H2 |C2 )P(C2 ) + P(H2 |C3 )P(C3 )
11 1 1 1
= +0 +1 = .
23 3 3 2
35
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Similarly
End of lecture 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
36
Chapter 6
Independence
The material of this chapter is based on Blitzstein & Hwang (2019), p.63-65, Anderson et al. (2018),
p.51-56, Grimmett & Welsh (1986), p.12-16.
37
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Let us now generalise the definition of independence to more than two events.
Definition 6.1.4 (Independence of events (general case)). 1. A finite collection of events A1 , . . . , An is
defined to be independent if
Remark 6.1.5. Note that pairwise independence of (Ai , Aj ) is in general not sufficient to conclude the
independence of (A1 , . . . , An ).
Example 6.1.6. The three events A1 , A2 , A3 are independent if and only if
Example 6.1.7. We roll two fair dice and write the sample space as Ω = {(i, j) : i, j = 1, . . . , 6}. We note
that card(Ω) = 62 = 36 and all outcomes are equally likely. We define three events: A1 = first roll is odd,
A2 = second roll is odd, A3 = sum is odd. Then A1 , A2 , A3 are pairwise independent, but they are not
independent since P(A1 ∩ A2 ∩ A3 ) = 0 ̸= P(A1 )P(A2 )P(A3 ).
If we, in addition, assume that P(B ∩ C) > 0, then equation (6.1.3) is equivalent to the condition
P(A|B ∩ C) = P(A|C).
Example 6.1.9. You have a fair and an ”unfair” coin. The unfair coin lands heads with probability 34 . You
pick one coin at random and toss it three times. It lands heads three times. Given this information, what is
the probability that you picked the fair coin?
Let A:=the chosen coin lands heads three times, F := you picked the fair coin. We want to find P(F |A).
We use the generalised Bayes rule and the fact that
3 3
1 1 3
P(F ) = = P(F c ), P(A|F ) = , P(A|F c ) = .
2 2 4
38
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Then:
1 3 1
P(A|F )P(F ) P(A|F )P(F ) 2 · 2
P(F |A) = = = ≈ 0.23.
P(A) P(A|F )P(F ) + P(A|F c )P(F c ) 1 3 1 3 3 1
2 · 2 + 4 · 2
After having seen that it landed heads three times, what is the probability that, if we toss the same coin
a fourth time, it lands heads a fourth time?
Let H := chosen coin lands heads at 4th toss. We want to find P(H|A). Here we use the law of total
probability with extra conditioning:
P(H|A) = P(H|A ∩ F )P(F |A) + P(H|A ∩ F c )P(F c |A).
Note that H and A are conditional independent given F since
3
1 1 1
P(H ∩ A|F ) = 4 = · = P(H|F )P(A|F ).
2 2 2
Hence P(H|A ∩ F ) = P(H|F ) = 21 . Similarly, P(H|A ∩ F c ) = P(H|F c ) = 43 . Hence
1 3
P(H|A) ≈ · 0.23 + (1 − 0.23) = 0.69.
2 4
A3
A1 A2
∪ni=1 Ai = A
39
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 6.1.15. Example of an increasing sequence of sets: Let Ω = R and define An := (−∞, n]. Then
A1 = (−∞, 1] ⊆ A2 = (−∞, 2] ⊆ A3 = (−∞, 3] ⊆ · · ·
with
∞
[
An ↑ A := An = Ω = R.
n=1
We note that the sequence of complements is decreasing: Acn ↓ Ac : We have Acn = (n, ∞) and hence
Ac1 = (1, ∞) = Ω ⊇ Ac2 = (2, ∞) ⊇ Ac3 = (3, ∞) ⊇ · · ·
with
∞
\
Acn ↓ Ac = Acn = ∅.
n=1
Next we will state and prove the continuity property of the probability measure1 .
The above theorem states that, for increasing or decreasing sets, we can interchange the limit operation
and the probability measure, i.e. we have
lim P(Ai ) = P( lim Ai ),
i→∞ i→∞
where the set limit on the right hand side needs to be understood as taking an infinite union or intersection
for increasing and decreasing sequences, respectively.
1 Recall that a sequence of real numbers (x ) is said to converge to a real number x if for all ϵ > 0 there exists an n ∈ N such
n 0
that for all n ≥ n0 we have |xn − x| < ϵ.
40
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Now let Ai ↓ A. Then Fi = Aci ↑ F = Ac . Then, we deduce from the first part of the proof that
limi→∞ P(Fi ) = P(F ). Using the properties of a probability measure, since P(Fi ) = 1 − P(Ai ) and
P(F ) = 1 − P(A), we deduce that limi→∞ P(Ai ) = P(A).
End of lecture 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
We can now formulate the so-called product rule for countable number of independent sets:
Theorem 6.1.17. If A1 , A2 , . . . is a countably infinite set of independent events, then
∞
! ∞
\ Y
P Ai = P(Ai ).
i=1 i=1
The proof of the above theorem relies on the continuity property of the probability measure.
P(∩∞
i=1 Ai ) = P(B) = lim P(Bn )
n→∞
n
Y ∞
Y
= lim P(∩ni=1 Ai ) = lim P(Ai ) = P(Ai ).
n→∞ n→∞
i=1 i=1
41
Chapter 7
The material of this chapter is based on Blitzstein & Hwang (2019), p.103-120, Grimmett & Welsh
(1986), p.24-28.
In this and the following chapter, we will be introducing discrete and continuous random variables and
their distributions.
Please not that the pre-image should not be confused with the inverse function (despite the fact that we
are using the same notation). The pre-image is well-defined for any function, whereas the inverse function
obviously only exists when the function f is invertible.
The definition of the pre-image implies that
x ∈ f −1 (B) ⇔ f (x) ∈ B.
Note that in the case when B is a singleton, i.e. B = {b} for an element b ∈ Y, then we often simplify
the notation to f −1 ({b}) = f −1 (b).
Lemma 7.1.2. For any collection of subsets Bi ⊆ Y, i ∈ I where I denotes an (arbitrary) index set, we
have that
!
[ [
−1
f Bi = f −1 (Bi ).
i∈I i∈I
42
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
X : Ω → R.
The function needs to satisfy some properties, which we introduce in the formal definition below. Note that
• Despite the name, a random variable is a function and not a variable.
i.e. the set of all ω which X maps to x. We require that this set is an event in F (for all possible x) so that
we can later assign probabilities to these events.
Definition 7.3.4 (Probability mass function). The probability mass function (pmf) of the discrete random
variable X is defined as the function pX : R → [0, 1] given by
43
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
We typically shorten the notation significantly and write pX (x) = P(X = x). Keep in mind, that this
is short hand notation for equation (7.3.1).
Note that the definition of the pmf implies the following properties:
pX (x) = 0 if x ̸∈ ImX.
since only countably many values of x result in non-zero values for the pmf and hence non-zero contribu-
tions to the sum.
Example 7.3.5. Consider the experiment where we toss a fair coin twice. Write H for heads and T for
tails. Then Ω = {HH, HT, T H, T T }. Define random variables on (Ω, P(Ω)).
• X = number of heads:
• Y = number of tails: Y = 2 − X.
• I = 1 if first toss lands heads and 0 otherwise.
This is a so-called indicator random variable indicating whether or not the first toss lands heads
(1=”yes”, 0=”no”).
We briefly check that X is a discrete random variable on (Ω, P(Ω)): Clearly, X : Ω → R and
ImX = {0, 1, 2} is finite. Also, X −1 (0) = {T T } ∈ P(Ω), X −1 (1) = {HT, T H} ∈ P(Ω), and
X −1 (2) = {HH} ∈ P(Ω).
For Y and I the arguments are analogous.
We can write 1 for H and 0 for T, then Ω = {(1, 1), (1, 0), (0, 1), (0, 0)} and P(Ω). I.e. ω = (ω1 , ω2 ) ∈
Ω if ωi ∈ {0, 1}, i = 1, 2. Then we can express the three random variables defined above as follows:
X(ω1 , ω2 ) = ω1 + ω2 ,
Y (ω1 , ω2 )) = 2 − ω1 − ω2 ,
I(ω1 , ω2 ) = ω1 .
Note that we can define the event A := {(1, 1), (1, 0)}, then I = IA . Also, note that
44
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
End of lecture 9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Theorem 7.3.6. Let I denote a countable (index) set. Suppose that S = {si : i ∈ I} is a countable set of
distinct real numbers and {πi : i ∈ I} is a collection of numbers satisfying
X
πi ≥ 0 for all i ∈ I, and πi = 1,
i∈I
then there exists a probability space (Ω, F, P) and a discrete random variable X on that probability space
such that its probability mass function is given by
Proof. This is a constructive proof: Take Ω = S, let F = P(Ω) be the power set (i.e. the set of all subsets
of Ω) and set
X
P(A) = πi for all A ∈ F.
i:si ∈A
Exercise 7.3.7. Can you think of an example of a probability space (Ω, F, P) and one function X : Ω → R
which is a random variable and one function Y : Ω → R which is not a random variable on that probability
space?
Please try solving the exercise before consulting the model solutions below. There are many possible
examples, one is stated below and you might find other ones which are equally correct!
Proof. Consider the sample space Ω = {1, 2, 3, 4, 5, 6} and define the event space F = {∅, Ω, {1, 3, 5}, {2, 4, 6}}.
Define the probability measure P to be the naive probability measure, i.e. P(A) = card(A)/card(Ω) for
A ∈ F.
(i) Define X : Ω → R such that X(ω) = 1 if ω is even and X(ω) = −1 if ω is odd. Then ImX =
{−1, 1} is finite and X −1 ({−1}) = {1, 3, 5} ∈ F and X −1 ({1}) = {2, 4, 6} ∈ F. For all
x ̸∈ ImX we have that X −1 ({x}) = ∅ ∈ F. Hence X is a discrete random variable.
(ii) Define Y : Ω → R such that Y (ω) = ω. Then e.g. Y −1 ({1}) = {1} ̸∈ F, hence Y is not a
(discrete) random variable with respect to the given sigma-algebra F. (It would be one if we had
chosen F = P(Ω) to be the power sigma-algebra of Ω as in the proof of Theorem 7.3.6!)
45
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
We write X ∼ Bern(p).
Note that for any event there is a natural way of associating a Bernoulli random variable with it: We
can define the so-called indicator variable of the event:
Definition 7.4.2 (Indicator variable). Consider an event A ∈ F, we denote by
1, if ω ∈ A,
IA (ω) =
0, if ω ̸∈ A,
Background: Think of an experiment with two possible outcomes ”success” or ”failure” (but not both).
We call such an experiment a Bernoulli trial. We can think of a Bernoulli random variable as an indicator
of success, where an outcome of 1 represents success and an outcome of 0 represents failure. Hence we
often call the parameter p in the Bernoulli distribution the success probability.
Definition 7.4.3 (Binomial distribution). A discrete random variable X is said to follow the binomial
distribution with parameters n ∈ N and p ∈ (0, 1) if ImX = {0, 1, . . . , n} and
n x
P(X = x) = p (1 − p)n−x , for x ∈ {0, 1, . . . , n},
x
46
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
0.25
0.20
Pmf of Bin(10,0.25)
0.15
0.10
0.05
0.00
0 2 4 6 8 10
0 2 4 6 8 10
x
0.15
0.10
0.05
0.00
0 2 4 6 8 10
x
47
(c) P.m.f. of X ∼ Bin(10, 0.75)
Figure 7.1: We depict the probability mass function for three random variables with binomial distribution
and parameters n = 10 and p ∈ {0.25, 0.5, 0.75}. Note that for p = 0.5 the pmf is symmetric about 5 and
skewed when p ̸= 0.5.
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
HGeom(500,200,10)
HGeom(500,200,30)
HGeom(500,200,50)
0.20
0.15
Pmf
0.10
0.05
0.00
0 10 20 30 40 50
Figure 7.2: This graph shows the probability mass function of the hypergeometric distribution with param-
eters N = 500, K = 200 and n ∈ {10, 30, 50}.
If we would like to show that the probability mass function of the hypergeometric distribution is indeed
a valid probability mass function, we typically use the Vandermonde’s identity which we will study next.
48
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
m
Remark 7.4.7. Note that we use the convention that, for n, m ∈ N0 , we set n = 0 if n > m.
Proof. Story proof/Combinatorial proof:
Consider selecting a committee of k people from a group of people consisting of m men and n women.
The left hand side describes the number of possibilities of selecting k from m + n people (without replace-
ment, order irrelevant). On the right hand side we consider all possible combinations when we choose i
men out of m men, then we need to choose k −i women out of n women to obtain a committee of k people.
We then need to sum of all possible values of i which gives us the right hand side.
Algebraic proof:
Using the binomial theorem, we get
X
m+n
m+n k
m+n
(1 + x) = x ,
k
k=0
Xm n m n
m i X n j X X m n i+j
(1 + x)m (1 + x)n = x x = x .
i=0
i j=0
j i=0 j=0
i j
X
m+n
m+n k
m+n
XX k
m n
m+n
(1 + x) = x = xk .
k i=0
i k − i
k=0 k=0
We note that two polynomials are identical if they have the same degree and the corresponding coefficients
are identical, which implies that for all 0 ≤ k ≤ n + m, we have
Xk
m+n m n
= .
k i=0
i k−i
49
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 7.4.9. Let C = {1, . . . , n}. If X ∼ DUnif(C), then P(X = x) = 1/n for all x ∈ {1, . . . , n}
and 0 otherwise.
0.20
0.15
Pmf of DUnif({1,2,3,4,5})
0.10
0.05
0.00
0 1 2 3 4 5 6 7
Figure 7.3: This graph shows the probability mass function of the discrete uniform distribution on the set
C = {1, 2, 3, 4, 5}.
Definition 7.4.10 (Poisson distribution). A discrete random variable X is said to follow the Poisson dis-
tribution with parameter λ > 0, i.e. X ∼ Poi(λ), if ImX = {0, 1, 2, . . .} = N ∪ {0} and
λx −λ
P(X = x) = e , for x = 0, 1, 2, . . . .
x!
We typically call the parameter λ in the Poisson distribution the rate or intensity [of the occurrence of
(rare) events].
50
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Pois(1)
Pois(5)
Pois(10)
0.3
0.2
Pmf
0.1
0.0
0 5 10 15 20
Figure 7.4: This graph shows the probability mass function of the Poisson distribution with three different
rate parameters: λ ∈ {1, 5, 10}.
We can think of an experiment where we carry out repeated (independent) Bernoulli trials with success
probability p. We stop the experiment after the first success. We denote by X the number of trials to obtain
the first success. Then we obtain that X ∼ Geom(p). Warning: If we set Y to be the number of failures
until first success we obtain a slightly different definition of the geometric distribution. Here we have that
ImY = N ∪ {0} and
51
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
0.7
Geom(0.7)
Geom(0.5)
Geom(0.2)
0.6
0.5
0.4
Pmf
0.3
0.2
0.1
0.0
2 4 6 8 10
Figure 7.5: This graph shows the probability mass function of the Geometric distribution with three differ-
ent success probabilities: p ∈ {0.7, 0.5, 0.2}.
The negative binomial distribution arises as the distribution of the number of failures in a sequence of
independent Bernoulli trials with success parameter p before r successes have occurred. To see this, let us
consider strings of ”0” (for failure) and ”1” (for success). Each string of r ”1”s and x ”0”s has probability
pr (1 − p)x . Now we need to find the number of such strings: We stop when we reach the rth success, so
the last element in the string will always be a ”1”. This leaves us with r + x − 1 positions, to which we
need to assign the remaining r − 1 ”1”s. Hence we obtain equation (7.4.1).
Remark 7.4.13. Recall that in the case of a Bin(n, p) distribution, we also consider a sequence of inde-
pendent Bernoulli trials, but we fix the number of trials n and count the number of successes.
52
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
0.07
NBin(5,0.3)
NBin(10,0.3)
0.06
NBin(20,0.3)
0.05
0.04
Pmf
0.03
0.02
0.01
0.00
0 20 40 60 80
Figure 7.6: This graph shows the probability mass function of the negative binomial distribution with
parameter p = 0.3 and r ∈ {5, 10, 20}.
In order to show that the pmf of the negative binomial distribution is a valid pmf, we study the general-
isation of the binomial coefficient:
Definition 7.4.14. For α ∈ C, k ∈ N, we define
α α(α − 1) · · · (α − k + 1)
:= .
k k!
The generalised binomial formula is then given by
X∞
α k
(1 + x)α = x , for |x| < 1.
k
k=0
Lemma 7.4.15 together with the generalised Binomial formula stated above can be used to show that if
X ∼ NBin(r, p) for p ∈ (0, 1), then
X∞ X∞ X∞
x+r−1 r x r x −r
P(X = x) = p (1 − p) = p (−1) (1 − p)x
x=0 x=0
r − 1 x=0
x
53
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
∞
X
−r
=p r
(p − 1)x = pr (1 + (p − 1))−r = pr p−r = 1,
x=0
x
7.4.8 Exercise
Exercise 7.4.16. Verify P
that all the probability mass functions listed above are valid in the sense that
pX (x) ≥ 0 for all x and x pX (x) = 1.
54
Chapter 8
The material of this chapter is based on Blitzstein & Hwang (2019), p.121-123, 213-244, Grimmett &
Welsh (1986), p.56-65.
Note that a discrete random variable (see Definition 7.3.1) satisfies the above definition of a random
variable. To see this, we can write
[
{ω ∈ Ω : X(ω) ≤ x} = {ω : X(ω) = y}.
y∈ImX:y≤x
The right hand side is a countable union of elements of F and (according the definition of the sigma-
algebra) hence also an element of F.
Remark 8.1.2. Note that, similarly to our previous definition, we call the set X −1 ((−∞, x]) = {ω ∈
Ω : X(ω) ≤ x} the pre-image of (−∞, x]. We can only make probability statements about the set
X −1 ((−∞, x]) if it is an element of the event space F which motivates our definition of a random variable.
Definition 8.1.3 (Cumulative distribution function (c.d.f.)). Suppose that X is a random variable on
(Ω, F, P), then the cumulative distribution function (c.d.f.) of X is defined as the mapping FX : R → [0, 1]
given by
Example 8.1.4. Consider a Bernoulli random variable X ∼ Bern(p). The c.d.f. of a Bernoulli random
variable is given by
X 0, for x < 0,
FX (x) = P(X ≤ x) = P(X = k) = 1 − p, for x ∈ [0, 1),
k≤x 1, for x ≥ 1.
55
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
P (X = k) 1.2
0.6
1
0.6
0.8
0.4
F (x)
0.4 0.6
0.4
0.2
0.2
0
0 −1 −0.5 0 0.5 1 1.5 2
−1 0 1 2 k x
Figure 8.1: Consider a Bernoulli random variable X with parameter p = 0.4. Its probability mass function
is depicted in Figure 8.1a and its cumulative distribution function in Figure 8.1b.
Then the result follows from the monotonicity of the probability measure, see the second statement
in Theorem 4.2.3.
2. Right continuity: We prove that if xn ↓ x (which is short-hand notation for a sequence (xn )n∈N ,
which is monotonically non-increasing, i.e. x1 ≥ · · · ≥ xn ≥ xn+1 ≥ · · · ≥ x and converging to x,
i.e. limn→∞ xn = x), then FX (xn ) → FX (x) as n → ∞. Define events
∞
\
En := {ω : X(ω) ≤ xn } ↓ En = {ω : X(ω) ≤ x} =: E.
n=1
Using the continuity of the probability measure, see Theorem 6.1.16, P(En ) → P(E). Since
P(En ) = FX (xn ), P(E) = FX (x), we have that FX (xn ) → FX (x) as n → ∞.
3. Limit behaviour at ±∞: Define for an xn
En = {ω : X(ω) ≤ xn }.
56
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Remark 8.1.6. One can show that for any function F which satisfies the three conditions stated in Theorem
8.1.5, there exists a probability space and a random variable on that space which has F as its c.d.f..
Note that in applications, we often use the following result:
Theorem 8.1.7. For a < b, we have P(a < X ≤ b) = FX (b) − FX (a).
Proof. Note that for a < b, we have
where the two events on the right hand side are disjoint. Hence
P({ω ∈ Ω : X(ω) ≤ b}) = P({ω ∈ Ω : X(ω) ≤ a}) + P({ω ∈ Ω : a < X(ω) ≤ b}),
Remark 8.1.8. A cumulative distribution function (c.d.f) of a random variable X, say, is right continuous,
but not in general left continuous. To see the latter, consider a point x ∈ R and an arbitrary sequence
(xn )n∈N approaching x from the left, i.e. x1 ≤ x2 ≤ · · · ≤ xn ≤ · · · ≤ x and limn→∞ xn = x. Then
∞
[
En := {ω ∈ Ω : X(ω) ≤ xn } ↑ En = {ω ∈ Ω : X(ω) < x} =: E.
n=1
So, we observe that FX is (left) continuous in x if and only if P({ω ∈ Ω : X(ω) = x}) = 0.
57
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
R∞
(ii) −∞
fX (u)du = 1.
We call fX the probability density function (p.d.f.) of X (or just the density).1
The so-called Fundamental Theorem of Calculus guarantees that a function FX given as in Definition
′
8.2.1 is differentiable at every point x where f is continuous with FX (x) = fX (x).
Remark 8.2.2. Note that fX (x) is not a probability and while fX is non-negative it is not restricted to be
smaller than 1.
We compare properties of the p.m.f. and the p.d.f. in the following table:
Table 8.1: Comparing discrete and random variables with p.m.f. pX and p.d.f. fX , respectively.
It turns out that, although fX (x) is not a probability, it can be linked to a probability when we scale it
appropriately. Consider a small quantity which we shall denote by dx > 0. Then the probability that X is
close to x can be written as
Z x+dx
P(x < X ≤ x + dx) = FX (x + dx) − FX (x) = fX (u)du ≈ fX (x)dx.
x
So, we can view the quantity fX (x)dx as the continuous analogue to a probability mass function pX (x).
The reason why we typically do not consider point probabilities for continuous random variables be-
comes clear in the next theorem.
Theorem 8.2.3. For a continuous random variable X with density fX , we have
P(X = x) = 0, for all x ∈ R, (8.2.2)
and
Z b
P(a ≤ X ≤ b) = fX (u)du, for all a, b ∈ R with a ≤ b. (8.2.3)
a
Proof. Consider any x ∈ R with a sequence xn ↑ x (i.e.(xn )n∈N , with limn→∞ xn = x and x1 ≤ x2 ≤
· · · ≤ xn ≤ · · · ≤ x), and define events
En = {ω : xn < X(ω) ≤ x} ↓ E = {ω : X(ω) = x}.
Using the continuity of the probability measure, see Theorem 6.1.16, P(En ) → P(E). Hence we can write
P(X = x) = lim P(En ) = lim P({ω : xn < X(ω) ≤ x})
n→∞ n→∞
= lim (FX (x) − FX (xn ))
n→∞
Z x
= lim fX (u)du = 0.
n→∞ xn
Now, let a ≤ b, then we know from the above that P(X = a) = 0, hence
P(a ≤ X ≤ b) = P(a < X ≤ b) = FX (b) − FX (a),
where we used Theorem 8.1.7.
1 In a later analysis/measure course we will say that equation 8.2.1 means that the ”c.d.f. of a continuous random variable is
58
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Remark 8.2.4. Combining the results from Remark 8.1.8 and Theorem 8.2.3 we conclude that the c.d.f. of
a continuous random variable is continuous. It is important to remember that the definition of the con-
tinuous random variable guarantees the existence of the density and then the continuity of the associated
c.d.f. follows from the properties of the (improper) Riemann integral. Note that if you only assumed that a
random variable X has a continuous c.d.f. with, in particular, P(X = x) = 0 for all x, then the existence
of a density function is not guaranteed. A notorious example of such a case is the so-called Cantor function
which you might study in a later analysis/measure course and another example we will discuss later, see
Example 8.4.1.
8.3.2 Exponential
λ=2 1
λ=1
λ = 0.5
FX (x)
fX (x)
0
0 1 2 3 4 5 0 1 2 3 4 5
x x
Figure 8.2: Plot of the p.d.f. (left) and the c.d.f. (right) of an Exp(λ) random variable for λ ∈ {0.5, 1, 2}.
59
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Definition 8.3.2 (Exponential distribution). A continuous random variable X is said to have the exponen-
tial distribution with parameter λ > 0, i.e. X ∼ Exp(λ), if its density function is given by
λe−λx , if x > 0,
fX (x) =
0, otherwise.
60
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
8.3.5 F-distribution
Definition 8.3.5 (F-distribution). A continuous random variable X is said to have the F-distribution with
d1 , d2 > 0 degrees of freedom, i.e. X ∼ F (d1 , d2 ) (or also X ∼ Fd1 ,d2 ) , if its density function is given by
d /2
d +d
Γ( 1 2 2 ) d12
d 1
xd1 /2−1
(d +d )/2 , if x > 0,
fX (x) =
d d d 1 2
Γ( 21 )Γ( 22 ) 1+ d1 x
2
0, otherwise.
X1 /n
X= ∼ Fn,m .
X2 /m
61
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
1.00 y
0.75
2 Rx 2
φ(x) = √1 e−x /2
Φ(x) = √1 e−t /2
dt
2π 2π −∞
0.50
0.25 √
1/ 2π ≈ 0.3989
−2 −1 0 1 x 2
Figure 8.3: The red solid line depicts the standard Gaussian probability density function and the blue
dashed line the corresponding cumulative distribution function.
y = φ(x)
Φ(−x0 ) 1 − Φ(x0 )
x
−x0 x0
Figure 8.4: Note that the standard normal density is symmetric around 0, i.e. ϕ(x) = ϕ(−x) for all x. This
also implies that Φ(−x) = 1 − Φ(x).
Definition 8.3.8 (Normal distribution). Let µ denote a real number and let σ > 0. A random variable X
has the normal/ Gaussian distribution with mean µ and variance σ 2 if it has density function
1 (x−µ)2
f (x) = √ e− 2σ 2 , for x ∈ R.
2πσ 2
Note that we typically write X ∼ N(µ, σ 2 ).
62
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
1.00 y
µ = 0, σ = 0.5
0.75
(x−µ)2
f (x) = √1
σ 2π
e− 2σ2
µ = 0, σ = 1
0.50
µ = 0.5, σ = 0.5
0.25
−2 −1 0 1 2
Figure 8.5: The red line depicts the standard Gaussian probability density function and the two blue lines
show non-standard Gaussian probability density functions.
fX (x) = √ ν
1 + , for x ∈ R.
νπΓ 2 ν
63
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 8.4.1. We flip an unfair coin infinitely many times and assume that we obtain heads with proba-
bility p ∈ (0, 1). We denote the outcomes by X1 , X2 , . . . with Xi = 0 if we obtain tails in the ith flip and
Xi = 1 if we obtain heads in the ith flip. Define a random number
Then
• X1 determines whether Y is in the first half [0, 21 ) (if X1 = 0) or in the second half [ 21 , 1] (if X1 = 1).
• X2 determines whether Y is in the first half (if X2 = 0) (either in [0, 14 ) or in [ 12 , 34 )) or in the second
half (if X2 = 1) (either in [ 41 , 12 ) or in [ 43 , 1]) of the previous half.
• etc.
We note that for any y = 0.x1 x2 x3 . . . in base 2 representation, we have
since each term in the product is either equal to p or 1 − p which are both smaller than 1, so their infinite
product will converge to 0. Hence Y cannot be a discrete random variable.
One (not we!) can show that for p ̸= 0.5, Y does not have a density, whereas if p = 0.5, then Y is
uniformly distributed on [0, 1] and hence has a density.
64
Chapter 9
The material of this chapter is based on Blitzstein & Hwang (2019), p.123-129, Grimmett & Welsh
(1986), p.28-29, 65-67.
Let us consider a random variable X on (Ω, F, P) and a (deterministic) function g : R → R. Clearly
Y = g(X) is a mapping from Ω to R with Y (ω) = g(X(ω)). In this chapter, we would like to study under
which conditions Y is itself a random variable and we would like to study its distribution
since each event {ω ∈ Ω : X(ω) = x} ∈ F for all x ∈ R and, by the definition of a σ-algebra, a countable
union of elements of F is in F, too. Since X is discrete, we indeed have that {x ∈ ImX : g(x) = y} ⊆
ImX is (at most) countably infinite. Hence we can conclude that Y = g(X) is indeed a discrete random
variable.
65
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
so we are just summing up the probabilities for all values x for which g(x) = y. Here we used the fact
that the union in (9.1.2) is a countable union of disjoint events, hence Axiom (iii) of the definition of the
probability measure applies, see also the discussion before Example 7.3.5 for more details.
In the special case when g is invertible (i.e. bijective), then the pmf of Y can be expressed as
This condition is only satisfied if g satisfies some additional properties (e.g. if it is continuous or mono-
tone1 ).
Example 9.2.1. Consider a linear transformation of the random variable X. I.e. let a > 0, b ∈ R and
define g(x) = ax + b. Then Y = g(X) = aX + b is indeed a random variable and, for any y ∈ R its
c.d.f. is given by
y−b y−b
FY (y) = P(Y ≤ y) = P(aX + b ≤ y) = P X ≤ = FX .
a a
Assuming that X is a continuous random variable, we can now differentiate (with respect to y– using the
chain rule) and obtain
y−b 1 1 y−b
fY (y) = FY′ (y) = FX
′
= fX .
a a a a
In the previous example, we have seen that in the case that the function g can be inverted, we can find
an explicit formula for the corresponding density of the transformed random variable. We can now state
and prove this result in a more general form.
Theorem 9.2.2. Suppose that X is a continuous random variable with density fX and g : R → R is
strictly increasing/decreasing and differentiable with inverse function denoted by g −1 , then Y = g(X) has
density
d −1
fY (y) = fX (g −1 (y)) [g (y)] , for all y ∈ R. (9.2.1)
dy
Proof. First, suppose that g is strictly increasing. Then, for any y ∈ R, we have
66
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
and hence
d −1 d −1
fY (y) = −fX (g −1 (y)) [g (y)] = fX (g −1 (y)) [g (y)] ,
dy dy
d −1
since in this case dy [g (y)] < 0.
Remark 9.2.3. In the proof above, we used the following result from Analysis: If g : R → R is a strictly
increasing (decreasing) function, then its inverse function denoted by g −1 is also strictly increasing (de-
creasing).
d −1
Remark 9.2.4. We typically call the term dy [g (y)] the Jacobian of the transformation.
Remark 9.2.5. You might remember equation (9.2.1) more easily when you write x = g −1 (y) and note
that
dx
fY (y) = fX (x) .
dy
In the case when g is strictly increasing, you can remove the absolute value signs and you get the pretty
symmetric formula:
fY (y)dy = fX (x)dx.
If X is continuous and we want to find the c.d.f. and/or the p.d.f. of Y = g(X) in the case when g is
not necessarily strictly increasing/decreasing, then we compute
Differentiating leads to
1 −1/2 √ 1 −1/2 √
fY (y) = y fX ( y) − − y fX (− y)
2 2
1 √ √
= √ [ϕ( y) + ϕ(− y)]
2 y
1 1 1 1 1
= √ 2 √ exp − y =√ exp − y ,
2 y 2π 2 2πy 2
67
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
68
Chapter 10
The material of this chapter is based on Blitzstein & Hwang (2019), p.149-174, Grimmett & Welsh
(1986), p.29-32, 67-70, 90-92.
This chapter introduces the expectation of a random variable. We will distinguish the two cases of
a discrete and continuous random variable and study the so-called law of the unconscious statistician
(LOTUS). We will also learn that the expectation is a linear operator and we will introduce the concept of
a variance and other (higher) moments.
Definition 10.1.2 (Expectation of a continuous random variable). For a continuous random variable X
with density fX , we define the expectation of X as
Z ∞
E(X) = xfX (x)dx,
−∞
R∞
provided that −∞
|x|fX (x)dx < ∞.
As in the discrete case, we often refer to the expectation as mean or expected value.
Remark 10.1.3. Recall that we said that pX (x) for a discrete random variable is comparable to fX (x)dx
for a continuous random variable. Also, in the discrete case, we deal with sums, whereas in the continuous
case we have integrals. Using these analogies it makes sense to use the definition
P
E(X) = R ∞ x xpX (x) if X is discrete,
−∞
xf X (x)dx if X is continuous.
1 This assumption matters in the case when ImX is infinite. If the sum converges absolutely, then the sum takes the same value
69
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Remark 10.1.4. Note that the above definition of the expectation ensures that the expectation is finite. We
can relax that definition slightly and allow for infinite expectations as well. In doing that, we need to be a
bit more careful with the precise definition. We can proceed as follows.
Suppose X is a non-negative discrete/continuous random variable with pmf pX /pdf fX . Then, define
P
E(X) = R ∞x≥0 xpX (x) if X is discrete,
(10.1.1)
0
xf X (x)dx if X is continuous.
Here the sum/integral is allowed to take the value +∞.
For a general discrete/continuous random variable, which is not necessarily restricted to be non-
negative, we can define its positive and negative parts as follows:
X + = max{0, X}, X − = max{0, −X}.
Since both X + and X − are non-negative, we can now define E(X + ) and E(X − ) as in (10.1.1). Here the
expectations can take the value +∞.
Since
X = X + − X −,
we can then define E(X) as
E(X) = E(X + ) − E(X − ),
provided the right hand side is not of the form ∞ − ∞, in which case we would say that the corresponding
expectation is undefined.
Hence
X X
E(Y ) = yP(Y = y) = yP(g(X) = y)
y∈ImY y∈ImY
X X
= y P(X = x)
y∈ImY x∈ImX:g(x)=y
X X
= yP(X = x)
x∈ImX y∈ImY :y=g(x)
X X
= g(x)P(X = x)
x∈ImX y∈ImY :y=g(x)
X
= g(x)P(X = x),
x∈ImX
where we were allowed to interchange the order of summation since the sum converges absolutely.
70
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 10.2.2. Consider a Bernoulli random variable X ∼ Bern(p). We compute its mean as follows:
X
E(X) = xP(X = x) = 0 · P(X = 0) + 1 · P(X = 1) = P(X = 1) = p.
x
Example 10.2.5. Take g(x) = xk for k ∈ N. Then E(X k ) is called the kth moment of X (provided it
exists).
The LOTUS theorems imply the linearity of the expectation in the following sense:
Theorem 10.2.6. Consider a discrete/continuous random variable X with finite expectation.
1. If X is non-negative, then E(X) ≥ 0.
2. If a, b ∈ R, then E(aX + b) = aE(X) + b.
Proof. The proof is left as an exercise, see Exercise 6- 2.
Example 10.2.7. Let X be a continuous random variable with density fX (x) = cx2 for x ∈ [0, 2] and
fX (x) = 0 otherwise. Find c and E(X) and E(X 2 ). The probability density function needs to be nonneg-
ative and integrate to 1, hence we set
Z ∞ Z 2 2
1 8
1= fX (x)dx = c x2 dx = c x3 =c ,
−∞ 0 3 0 3
2 We assume that the function g is such that g(X) is also a continuous random variable.
71
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
10.3 Variance
While the expectation tells you something about the centre of the distribution, in many applications we also
want to know about the dispersion of X about its mean value. Hence we introduce the so-called variance
Definition 10.3.1 (Variance). Let X be a discrete/continuous random variable. Then its variance is defined
as
Proof. In order to simplify the notation we write µ = E(X). In the discrete case we have, using Theorem
10.2.1,
X
Var(X) = E[(X − µ)2 ] = (x2 − 2µx + µ2 )pX (x)
x
X X X
2
= x pX (x) + (−2µx)pX (x) + µ2 pX (x)
x x x
X X X
= x2 pX (x) − 2µ xpX (x) + µ2 pX (x)
x x x
= E(X 2 ) − 2µE(X) + µ2 = E(X 2 ) − [E(X)]2 .
A very useful property of the variance is that it is not affected by deterministic additions and a multi-
plicative constant can be taken out of the variance provided we square it:
Theorem 10.3.3. Let X be a discrete/continuous random variable with finite variance and consider deter-
ministic constants a, b ∈ R. Then
Var(aX + b) = a2 Var(X).
72
Chapter 11
The material of this chapter is based on Blitzstein & Hwang (2019), p.594–596.
In this bridging lecture we will state the main concepts from multivariate calculus which we will need
in the Y1 Probability and Statistics course in order to be able to study multivariate random variables. More
details of this material will be provided in the Analysis and Calculus courses at a later point in time.
In this lecture, we will focus on bi-variable calculus only, but the concepts will extend to the general
multivariate case.
f (x, y) = xy 2 + x3 y.
We would like to find the partial derivative with respect to x. Then we treat the variable y as a constant
and differentiate the function g(x) := f (x, y) in the usual way with respect to x. This leads to
∂f (x, y) d
= g(x) = y 2 + 3x2 y.
∂x dx
Similarly, if we would like to find the partial derivative with respect to y, then we treat the variable x
as a constant and differentiate the function h(y) := f (x, y) in the usual way with respect to y. This leads
to
∂f (x, y) d
= h(y) = 2xy + x3 .
∂y dy
The partial derivatives above are so-called first order partial derivatives. Repeating the steps above, by
taking partial derivatives of the partial derivatives, we get second order partial derivatives. In our example,
this leads to
∂ 2 f (x, y) ∂ ∂f (x, y)
= = 2y + 3x2 .
∂y∂x ∂y ∂x
We note that it does not matter in which order we differentiate and we get the same result when we compute
∂ 2 f (x, y) ∂ ∂f (x, y)
= = 2y + 3x2 .
∂x∂y ∂x ∂y
Under mild technical assumptions, we have for a general function f that
∂ 2 f (x, y) ∂ 2 f (x, y)
=
∂x∂y ∂y∂x
73
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Consider a transformation which maps x = (x1 , x2 ) to y = (y1 , y2 ). Then the Jacobian of the
transformation is defined as the 2x2 matrix of all possible first order partial derivatives:
!
∂y1 ∂y1
∂y ∂x1 ∂x2
= ∂y2 ∂y2
∂x ∂x1 ∂x2
and the joint integral can be computed by iteratively computing the univariate integrals. I.e., similar to the
concept of partial derivatives, we can compute multiple integrals by treating the variable which is not the
integration variable constant and integrate out one variable at a time. We illustrate this idea in an example.
Let A = {(x, y) : 0 ≤ x ≤ y ≤ 1} ⊆ R2 and f (x, y) = xy 2 + x3 y. First we will be integrating with
respect to x and then with respect to y:
Z Z Z 1 Z y Z 1 y
1 2 2 1 4
f (x, y)dxdy = (xy 2 + x3 y)dxdy = x y + x y dy
A 0 0 0 2 4 0
Z 1
1 4 1 5
= y + y dy
0 2 4
1
11 5 11 6 1 1 17
= y + y = + = .
25 46 0 10 24 120
Alternatively, we can also integrate with respect to y first and then with respect to x. When switching the
order of integration, we need to carefully check the area of integration defined by A. Then we have
Z Z Z Z Z !
1 1 1 1
1 3 1 3 2
f (x, y)dydx = (xy 2 + x3 y)dydx = xy + x y dx
A 0 x 0 3 2 x
Z 1
1 1 3 1 4 1 5
= x + x − x − x dx
0 3 2 3 2
1
11 2 11 4 11 5 11 6
= x + x − x − x
23 24 35 26 0
1 1 1 1 17
= + − − = .
6 8 15 12 120
74
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
x = r cos(θ), y = r sin(θ),
for r > 0 and θ ∈ [0, 2π). Then, we compute the Jacobian determinant J(r, θ) of the transformation as
follows:
∂(x, y) cos(θ) −r sin(θ)
J(r, θ) = det = det = r(cos2 (θ) + sin2 (θ)) = r.
∂(r, θ) sin(θ) r cos(θ)
Then,
Z 2π
Z ∞
1
I= exp − (r2 cos2 (θ) + r2 sin2 (θ)) |J(r, θ)|drdθ
0 0 2
Z 2π Z ∞
1
= exp − r2 rdrdθ.
0 0 2
You can now do another variable transformation (or integrate directly): We set u = r2 /2, the du = rdr
and
Z 2π Z ∞ Z 2π Z 2π
∞
I= e−u du dθ = −e−u u=0 dθ = 1dθ = 2π.
0 0 0 0
√ √
Hence, we have that I = 2π. Now you might wonder why we do these kind of computations in the
probability course...
Suppose you would like to check that the standard normal density is indeed a valid density and, apart
from being nonnegative, satisfies
Z ∞ 2
1 x
√ exp − dx = 1. (11.3.2)
−∞ 2π 2
It turns out that this integral can be computed using the transformation to polar coordinates used above. To
this end, note that showing equation (11.3.2) is equivalent to showing that
Z ∞
x2 √
exp − dx = 2π.
−∞ 2
Squaring both sides leads to
Z ∞ 2 2
x
exp − dx = 2π.
−∞ 2
1 For instance, we need that the partial derivatives in the Jacobian exist and are continuous and that the Jacobian determinant is
never 0.
75
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Z 2 2 Z ∞
∞ 2 Z ∞ 2
x x y
exp − dx = exp − dx · exp − dy
−∞ 2 −∞ 2 −∞ 2
Z ∞Z ∞
1
= exp − (x2 + y 2 ) dxdy = I.
−∞ −∞ 2
R∞
Since we have already shown that I = 2π, we can conclude that −∞ ϕ(x)dx = 1.
In the next chapter, we will also show how the change of variables formula can be applied in the context
of transformations of multivariate random variables.
End of bridging lecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
76
Chapter 12
The material of this chapter is based on Blitzstein & Hwang (2019), p.129-133, 303-306, 312-313,
Grimmett & Welsh (1986), p.36-43, 75-88.
• FX,Y is continuous from above (the multivariate version of right-continuity), i.e., for two sequences
(xn ), (yn ) which approach x and y from the right as n → ∞ we get that FX,Y (xn , yn ) → FX,Y (x, y).
• We have the following two limits:
lim FX,Y (x, y) = 0, lim FX,Y (x, y) = 1.
x→−∞,y→−∞ x→∞,y→∞
Example 12.1.2. Let FX,Y denote the joint c.d.f. of (X, Y ). For x, y ∈ R, find an expression for P(X ≤
x, Y ≥ y) in terms of FX,Y . We note that
Law of total prob.
P(X ≤ x, Y ≥ y) + P(X ≤ x, Y < y) = P(X ≤ x) = FX,Y (x, ∞).
Also, P(X ≤ x, Y < y) = FX,Y (x, y−). Hence,
P(X ≤ x, Y ≥ y) = FX,Y (x, ∞) − FX,Y (x, y−).
77
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
12.2 Independence
We have now all the tools to define what we mean by independence of (general) random variables: We call
random variables X and Y independent if the events {ω ∈ Ω : X(ω) ≤ x} and {ω ∈ Ω : Y (ω) ≤ y} are
independent for all x, y ∈ R. I.e. we define:
Definition 12.2.1 (Independence of random variables). The random variables X and Y are independent if
and only if
which is equivalent to saying that the joint distribution function factorises as the product of the two
marginal distribution functions:
or equivalently if
Definition 12.2.2 (Pairwise independence for n ∈ N, n > 2 random variables). We call the random
variables X1 , . . . , Xn pairwise independent if
FXi ,Xj (xi , xj ) = FXi (xi )FXj (xj ), for all xi , xj ∈ R whenever i ̸= j.
Remark 12.2.3. Independence of random variables implies pairwise independence, the reverse statement,
however, is not true in general.
Finally, we define what we mean by independence of a family of (infinitely many) random variables.
Definition 12.2.4 (Independence of a family of random variables). Let I ⊂ R denote an index set. A
family of random variables {Xi : i ∈ I} is said to be independent if for all finite subsets J ⊆ I and all
xj ∈ R, j ∈ J , the following product rule holds:
Y
P(∩j∈J {Xj ≤ xj }) = P(Xj ≤ xj ).
j∈J
Remark 12.2.5. Note that for independent random variables X1 , . . . Xn , and continuous functions fi :
R → R for i = 1, . . . , n the transformed random variables Y1 = f1 (X1 ), . . . , Yn = fn (Xn ) are also
independent. [It would be sufficient to assume that functions fi are Borel-measurable, but this concept is
beyond the scope of this course.]
78
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
12.3.1 Independence
Definition 12.2.1 covers the case of general random variables. In the discrete (or continuous) case, we can
formulate equivalent independence conditions:
Definition 12.3.2 (Independence of discrete random variables). Suppose that X and Y are discrete random
variables on a probability space (Ω, F, P). X and Y are said to be independent if the pair of events
{ω ∈ Ω : X(ω) = x} and {ω ∈ Ω : Y (ω) = y} are independent for all x, y ∈ R, i.e. if
79
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Similar to the univariate case, we typically obtain the joint density by differentiating the joint distribu-
tion function. I.e. we take
(
∂2
fX,Y (x, y) = ∂x∂y FX,Y (x, y), if this derivative exists at (x, y),
0, otherwise.
and also
Z ∞
fY (y) = fX,Y (u, y)du.
u=−∞
12.4.1 Independence
From our definition of independence of random variables, see Definition 12.2.1, we can immediately de-
duce by differentiating/integrating that jointly continuous random variables X and Y are independent if
and only if their joint density factorises:
fX,Y (x, y) = fX (x)fY (y), for all x, y ∈ R.
12.4.2 Examples
Example 12.4.2. Suppose the joint density of (X, Y ) is given by
( 2
√7 e−x /2−7y , if − ∞ < x < ∞, y > 0,
fX,Y (x, y) = 2π
0, otherwise.
We want to check whether or not X and Y are independent and compute P(X > 2, Y < 1). We note that
for x ∈ R, y > 0, we can write
1 2
fX,Y (x, y) = √ e−x /2 · 7e−7y ,
2π
which is in fact the product of a standard normal random variable and an Exp(7) random variable. Hence,
we have fX,Y (x, y) = fX (x)fY (y) for all x, y ∈ R which implies independence. Hence
P(X > 2, Y < 1) = P(X > 2)P(Y < 1) = (1 − Φ(2))FY (1)
= (1 − Φ(2))(1 − e−7 ).
The following is a worked example where you can practice doing computations involving bivariate
p.d.f.s and c.d.f.s.
Example 12.4.3 (Reading material: Worked example). Consider jointly continuous random variables
X, Y with joint density given by
c(x2 + y 2 ), for 0 < x < 2, 0 < y < 2,
fX,Y (x, y) =
0, otherwise.
80
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
∂ 2 FX,Y (x, y)
fX,Y (x, y) = = 0.
∂x∂y
1 3
Case 2: Let x, y ∈ (0, 2): FX,Y (x, y) = 32 (x y + xy 3 ). Hence
∂ 2 FX,Y (x, y) ∂ ∂ 1 3 3 ∂ 1 2 3
fX,Y (x, y) = = (x y + xy ) = (3x y + y )
∂x∂y ∂y ∂x 32 ∂y 32
1 3 2
= (3x2 + 3y 2 ) = (x + y 2 ).
32 32
1 3 ∂ 2 FX,Y (x,y)
Case 3: Let x ∈ (0, 2), y ≥ 2: FX,Y (x, y) = 16 x + 14 x. Hence fX,Y (x, y) = ∂x∂y = 0.
2
1 3 ∂ FX,Y (x,y)
Case 4: Let y ∈ (0, 2), x ≥ 2: FX,Y (x, y) = 16 y + 14 y. Hence fX,Y (x, y) = ∂x∂y = 0.
2
∂ FX,Y (x,y)
Case 5: Let x, y ≥ 2: FX,Y (x, y) = 1. Hence fX,Y (x, y) = ∂x∂y = 0.
4. Find the marginal densities of X and Y .
Z Z !
∞ 2 2
1
fX (x) = fX,Y (x, y)dy = c(x + y )dy = c x2 y + y 3
2 2
−∞ 0 3 y=0
8 3 2 1
= c 2x2 + = x + ,
3 16 4
3 2
for x ∈ (0, 2) and fX (x) = 0 otherwise. By symmetry, fY (y) = 16 y + 14 , for y ∈ (0, 2) and
fY (y) = 0 otherwise.
81
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
U = u(X, Y ), V = v(X, Y ).
and assume that T is a bijection from the domain D = {(x, y) : fX,Y (x, y) > 0} ⊆ R2 to some range
S ⊆ R2 . Then we can write T −1 : S → D for the inverse mapping of T , i.e. (x, y) = T −1 (u, v). For the
first component we write x = x(u, v) and for the second y = y(u, v). The Jacobian determinant of T −1
is defined as the determinant
∂x ∂x
∂u ∂v
∂x ∂y ∂x ∂y
J(u, v) = det ∂y ∂y = − .
∂u ∂v ∂u ∂v ∂v ∂u
Example 12.5.1. Let us demonstrate how the methodology works in practice, see Grimmett & Welsh (1986,
p. 87).
Suppose that X, Y ∼ Exp(1) are independent. Define
X
U := X + Y, V := .
X +Y
We want to find the joint density of (U, V ) and the marginal densities of U and V .
First, we note that the joint density of (X, Y ) is – due to independence – given by
82
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
where T maps the set D = {(x, y) : x, y > 0}, onto S = {(u, v) : 0 < u < ∞, 0 < v < 1}.
Next, we find the inverse function of T :
and zero otherwise. Hence, U ∼ Gamma(2, 1). The marginal density of V is given by
Z ∞ Z ∞
fV (v) = fU,V (u, v)du = u exp(−u)du = Γ(2) = 1, for 0 < v < 1,
0 0
Theorem 12.6.2 (2D LOTUS: continuous case). Let X, Y be jointly continuous random variables with
density fX,Y and let h : R2 → R. Then
Z ∞Z ∞
E[h(X, Y )] = h(x, y)fX,Y (x, y)dxdy.
−∞ −∞
83
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Theorem 12.6.3 (Linearity of expectation). Let X, Y denote jointly discrete/continuous random variables
on (Ω, F, P), and a, b ∈ R, then
= aE(X) + bE(Y ).
In the continuous case, we apply Theorem 12.6.2 with g(x, y) = ax + by. Then
Z ∞Z ∞
E(aX + bY ) = (ax + by)fX,Y (x, y)dxdy
−∞ −∞
Z ∞Z ∞ Z ∞Z ∞
=a xfX,Y (x, y)dxdy + b yfX,Y (x, y)dxdy
−∞ −∞ −∞ −∞
Z ∞ Z ∞
=a xfX (x)dx + b yfY (y)dy
−∞ −∞
= aE(X) + bE(Y ).
Using induction, one can easily deduce that for n ∈ N and random variables X1 , . . . , Xn with finite
expectations and constants a1 , . . . , an ∈ R we have
Remark 12.6.4. It is important to remember that the linearity of the expectation (12.6.1) holds in general
without assuming any independence between the random variables.
if the expectation on the right hand side takes a finite value. Also, we define the correlation of X and Y as
Cov(X, Y )
Cor(X, Y ) = p .
Var(X)Var(Y )
For concrete computations it is often useful to work with the following alternative expression for the
covariance.
84
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Theorem 12.7.2 (Covariance). For jointly discrete/continuous random variables X, Y with finite expecta-
tions, we have
1. Find Cov(X, Y ).
We note that Cov(X, Y ) = E(XY ) − E(X)E(Y ).
Recall that
Z Z !
∞ 2 2
1
fX (x) = fX,Y (x, y)dy = c(x + y )dy = c x2 y + y 3
2 2
−∞ 0 3 y=0
8 3 2 1
= c 2x2 + = x + ,
3 16 4
for x ∈ (0, 2) and fX (x) = 0 otherwise. Then
Z ∞ Z 2 2
3 3 1 3 1 4 1 1 2 3 1 5
E(X) = xfX (x)dx = x + x dx = · x + · x = + = .
−∞ 0 16 4 16 4 4 2 x=0 4 2 4
2. Find Cor(X, Y ).
Recall that Var(X) = E(X 2 ) − (E(X))2 . Here we have
Z ∞ Z 2 2
2 LOTUS 2 3 4 1 2 3 1 5 1 1 3
E(X ) = x fX (x)dx = x + x dx = · x + · x
−∞ 0 16 4 16 5 4 3 x=0
6 2 28
= + = .
5 3 15
Hence
28 52 73
Var(X) = E(X 2 ) − (E(X))2 = − 2 = ,
15 4 240
85
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
73
and by symmetry Var(Y ) = 240 . Hence
Cov(X, Y ) −1 15
Cor(X, Y ) = p = 7316 = − ≈ −0.2.
Var(X)Var(Y ) 240
73
Remark 12.7.4. It is important to note that independent random variables always have zero covariance,
but the converse does not hold in general!
A very important property of independent random variables is the fact that the expectation of their
product can be written as the product of their expectation (a property which does not hold in general!):
Theorem 12.7.5. Let X, Y denote independent and jointly discrete/continuous random variables with
finite expectation, then
Proof. In the case when X, Y are jointly discrete, we use Theorem 12.6.1 with g(x, y) = xy. Then
XX
E(XY ) = xyP(X = x, Y = y)
x y
XX
= xyP(X = x)P(Y = y) (by independence)
x y
X X
= xP(X = x) yP(Y = y) (using the existence of E(X), E(Y ))
x y
= E(X)E(Y ).
Using Theorem 12.6.2 and similar computations as above gives us the result for the jointly continuous
case.
Remark 12.7.6. It is important to note that if E(XY ) = E(X)E(Y ), then this does not in general imply
that X and Y are independent, see Exercise 6- 6.
The results stated in Theorem 12.7.5 can be extended to the n ∈ N dimensional case by induction: If
X1 , . . . , Xn are independent, then
In statistics, we often deal with sums of random variables. How can we compute their variance? The
following theorem gives an answer.
Theorem 12.7.7 (Variance of a sum of random variables). Let X, Y denote two jointly discrete/continuous
random variables with finite variances. Then
86
Chapter 13
Generating functions
The material of this chapter is based on Blitzstein & Hwang (2019), p.279-293, Grimmett & Welsh
(1986), p.45-52.
In probability theory we often use so-called generating functions to derive/prove statements regarding
the distribution of random variables/vectors or to compute moments. In this course, we study so-called
probability generating functions and moment generating functions and we will give an outlook on what
characteristic functions are.
Then the probability generating function (pgf) of X is defined as the function GX : SX → R given by
∞
X
GX (s) = E(sX ) = sx P(X = x).
x=0
87
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Proof. Assume that (13.1.1) holds. First we note that GX (0) = GY (0) implies P(X = 0) = P(Y = 0).
When we differentiate1 the pgfs we get
∞
X
G′X (s) = xsx−1 P(X = x).
x=1
When we plug in s = 0 in the first derivative, we get G′X (0) = P(X = 1). Hence, G′X (0) = P(X = 1) =
P(Y = 1) = G′Y (0). This procedure can be repeated and we obtain
dn
GX (s) = n!P(X = n),
dsn s=0
the same can be done for GY , and the identity of the two pgfs implies the result.
The other direction of the proof is trivial.
Example 13.1.3. Let X be a discrete random variable with ImX ⊆ N ∪ {0}. Suppose that
1 1 5 1 10 4
GX (s) = + s + s + s12 .
3 5 5 15
Find the p.m.f. of X. Recall that
∞
X
GX (s) = E(sX ) = sx P(X = x) = P(X = 0) + sP(X = 1) + s2 P(X = 2) + · · · .
x=0
Hence, in the example above, we can just read off the probabilities:
1 1 1 4
P(X = 0) = , P(X = 5) = , P(X = 10) = , P(X = 12) = ,
3 5 5 15
and P(X = x) = 0 for x ̸∈ {0, 5, 10, 12}.
for all s ∈ R.
Example 13.1.5 (Binomial distribution). Let X ∼ Bin(n, p). Then
n
X n
GX (s) = E(sX ) = sx px (1 − p)n−x = (1 − p + sp)n ,
x=0
x
for all s ∈ R. Here we used the series expansion of the exponential function.
1 You will learn in the real analysis course under which conditions we are allowed to interchange the infinite sum and the derivative.
For the purpose of this course, we will just assume that the above computation is valid.
88
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Proof. Let s ∈ SX ∩ SY . Since X and Y are independent, Exercise 6- 7 implies that sX and sY satisfy the
product formula for expectations (in fact, they are also independent and Theorem 12.7.5 applies). Hence
using we conclude that
An immediate consequence of the above results is, that for independent non-negative integer-valued
random variables X1 , . . . , Xn (n ∈ N), we have
n
Y
GPni=1 Xi (s) = GXi (s),
i=1
13.1.3 Moments
We have already introduced, the mean and variance of a (discrete) random variable X. More generally, for
k ∈ N, we call E(X k ) the kth moment of X provided it exists. It turns out that we can use the probability
generating function for deriving moments of random variables. More precisely, we differentiate the pgf k
times and plug in s = 1:
Theorem 13.1.8. Let X be a discrete random variable with ImX ∈ N ∪ {0}. Let k ∈ N. Then the kth
derivative of the pgf is given by
dk
GX (s) = G(k) (1) = E[X(X − 1) · · · (X − k + 1)].
dsk s=1
Proof. As before, we assume that we are allowed to interchange derivatives and summation under suitable
conditions. Then
d d
GX (s) = E(sX ) = E(XsX−1 ).
ds ds
Hence
d
GX (s) = E(X).
ds s=1
Similarly,
dk d
k
GX (s) = E(sX ) = E[X(X − 1) · · · (X − k + 1)sX−k ].
ds ds
Hence
dk
GX (s) = E[X(X − 1) · · · (X − k + 1)].
dsk s=1
89
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Example 13.1.9 (Computing the variance using pgfs). The above theorem can be used for computing the
variance of a discrete non-negative integer-valued random variable X. We note that
G′′X (1) = E[X(X − 1)] = E(X 2 ) − E(X).
Hence,
Var(X) = E(X 2 ) − [E(X)]2 = G′′X (1) + G′X (1) − (G′X (1))2 .
Example 13.1.10. Compute the mean and variance of the Bernoulli, Binomial and Poisson distributions
using the probability generating functions.
• For X ∼ Bern(p), we have, for s ∈ R,
LOTUS
X
GX (s) = E(sX ) = sx P(X = x) = s0 P(X = 0) + s1 P(X = 1) = 1 − p + sp.
x
Then
d d2
GX (s) = p, GX (s) = 0.
ds s=1 ds2 s=1
Hence
E(X) = G′X (1) = p, Var(X) = G′′X (1) + G′X (1) − (G′X (1))2 = p − p2 = p(1 − p).
Hence
E(X) = G′X (1) = np,
Var(X) = G′′X (1) + G′X (1) − (G′X (1))2 = n2 p2 − np2 + np − (np)2 = np(1 − p).
Hence
E(X) = G′X (1) = λ,
Var(X) = G′′X (1) + G′X (1) − (G′X (1))2 = λ2 + λ − λ2 = λ.
90
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
MX (t) = E(etX ),
provided the expectation exists in some neighbourhood of zero, i.e. the expectation exists for all |t| < ϵ for
some ϵ > 0. Then
∞
! ∞
X (tX)n (∗) X tn
tX
MX (t) = E(e ) = E = E(X n ) .
n=0
n! n=0
n!
Note that, in general, we are not allowed to interchange an infinite sum with the expectation. However,
here the equality in (*) holds, since we assume the existence of the moment generating function in a neigh-
bourhood of zero.
Also, we can do a Taylor series expansion of MX (t) around 0, which leads to
∞
X tn
MX (t) = M n (0) .
n=0
n!
Clearly, for the two infinite series to be the same, we need that M (n) (0) = E(X n ).
Example 13.2.4. Let X ∼ N(0, 1). Then we use the trick of ”completing the square” in the second line:
Z ∞ Z ∞
tx 1 − 21 x2 1 1 2
MX (t) = e √ e dx = √ e− 2 x +tx dx
−∞ 2π −∞ 2π
Z ∞
1 − 1 (x2 −2tx+t2 ) t2
= √ e 2 e 2 dx
−∞ 2π
Z ∞
t2 1 1 2 t2
=e 2 √ e− 2 (x−t) dx = e 2 ,
−∞ 2π
since the latter integral is equal to 1 since it is the integral of a N(t, 1) density function. We note that the
m.g.f. exists for all t ∈ R in this case.
Let us now consider an example where the m.g.f. does not exist for all t ∈ R.
Example 13.2.5. Let X ∼ Exp(λ), then
Z ∞ Z ∞
MX (t) = E(etX ) = etx λe−λx dx = e(t−λ)x λdx
0 0
λ
λ−t , if t < λ,
=
∞, if t ≥ λ.
91
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
13.2.1 Properties
Theorem 13.2.6. If X has a m.g.f., then for k ∈ N, the kth moment of X is given by
(k) dk
E(X k ) = MX (0) = MX (t) .
dtk t=0
Proof. We give a sketch proof of the theorem. Assuming we can interchange expectation and differentia-
tion, we write
k
dk dk tX d tX
MX (t) = k E(e ) = E e = E X k etX ,
dtk dt dtk
which is the m.g.f. of an N(µ, σ 2 ) distributed random variable. We can find the mean of X, by
2 2
′
E(X) = MX (0) = eµt+σ t /2
(µ + σ 2 t) = µ.
t=0
Theorem 13.2.9. Let X1 , . . . , Xn denote a sequence of independent random variables with m.g.f.s MX1 , . . . , MXn .
Then
n
Y
MPni=1 Xi (t) = MXi (t).
i=1
Proof. Since the expectation of a product of independent random variables is the product of their corre-
sponding expectation, see Theorem 12.7.5, we have
" n
!# " n # n n
X Y Y Y
MPni=1 Xi (t) = E exp t Xi =E exp(tXi ) = E(etXi ) = MXi (t).
i=1 i=1 i=1 i=1
Here we used that continuous transformations (with f (x) = etx ) of independent random variables are
independent, too, see Remark 12.2.5.
We will now state without proof the famous characterisation theorem:
Theorem 13.2.10 (Characterisation). If the m.g.f.s of the random variables X and Y exist and MX (t) =
MY (t) in a neighbourhood of zero, then
The above theorem states that m.g.f. characterise the distribution of a random variable uniquely.
92
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
13.3 Using m.g.f.s for finding all moments of the exponential and the
standard normal distributions
Example 13.3.1. We would like to find all the moments of the exponential distribution:
• Let X ∼ Exp(1). Then MX (t) = (1 − t)−1 for all t < 1. Using the geometric series for |t| < 1, we
have
∞
X X∞ X∞
1 tn tn
MX (t) = = tn = n! = E(X n ) ,
1 − t n=0 n=0
n! n=0 n!
and FX (x) = 0 for x < 0, which is the c.d.f. of an Exp(1)-distributed random variable. Then, we
can deduce that, for all n ∈ N, we have
n!
E(X n ) = n! = E(λn Y n ) = λn E(Y n ) ⇔ E(Y n ) = .
λn
In particular, E(X) = λ−1 , Var(X) = λ−2 .
Example 13.3.2. We would like to find all the moments of the standard normal distribution: Let X ∼
N(0, 1). Then
X∞ X∞ ∞
X ∞
X
2 (t2 /2)n t2n (2n)! t2n t2n
MX (t) = et /2
= = n
= n
· = E(X 2n ) .
n=0
n! n=0
2 n! n=0 2 n! (2n)! n=0 (2n)!
(2n)!
I.e. E(X 2n ) = 2n n! and E(X 2n−1 ) = 0 for all n ∈ N.
The even moments can be computed using the following identity:
(2n)!
Lemma 13.3.3. 2n n! = (2n − 1)(2n − 3) · · · 3 · 1, for n ∈ N.
Proof. We can give a story proof/proof by interpretation. Both sides count how many ways there are to
break a group of 2n people into n pairs: Left hand side: Take 2n people and label them 1 to 2n. We can
line up the 2n people (there are (2n)! possible permutations) and say that the first two are a pair, the next
two are a pair etc. Here we overcount by a factor of n! since the order of the pairs does not matter and by a
factor of 2n since the order within each pair does not matter. Right hand side: There are 2n − 1 ways to
choose a partner for the first person, then there are 2n − 3 choices for person 2 (or 3 if 2 was already paired
to person 1) etc.
93
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
For a non-negative random variable X we sometimes work with the Laplace transform instead which
is defined as
94
Chapter 14
The material of this chapter is based on Blitzstein & Hwang (2019), p.306-311, 313-321, Grimmett &
Welsh (1986), p.32-33, 88-89, 92-95.
Let us now study conditional distributions both for discrete and continuous random variables. They
allow us to define the conditional expectation, which is a really useful concept as we shall see when stating
the law of total expectation.
14.1 Discrete case: Conditional expectation and the law of total ex-
pectation
We have already introduced the notation of conditional probabilities. Now we are going to define the
conditional distribution of a discrete random variable.
Definition 14.1.1 (Conditional distribution and conditional expectation). Let Y denote a discrete random
variable on the probability space (Ω, F, P). Consider an event B ∈ F such that P(B) > 0. The condi-
tional distribution of Y given B is defined as
P({Y = y} ∩ B)
P(Y = y|B) = , for y ∈ R.
P(B)
95
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Proof. First we use the definition of the expectation, followed by the law of total probability (Theorem
5.4.4):
X X X
E(Y ) = yP(Y = y) = y P(Y = y|Bi )P(Bi )
y y i∈I
X X X
= P(Bi ) yP(Y = y|Bi ) = P(Bi )E(Y |Bi ).
i∈I y i∈I
We use the fact that the series is absolutely convergent to justify that we are allowed to change the order of
summation.
pX,Y (x, y)
pY |X (y|x) = P(Y = y|X = x) = , for y ∈ R.
pX (x)
Note that we can also formulate an independence condition in terms of conditional p.m.f.s: Discrete X
and Y are independent if and only if
for all x, y such that P(X = x) > 0. Also, we get a Bayes’ type result of the form
14.1.2 Example
Let us study an example:
Example 14.1.3. Suppose you sit in Heathrow waiting for your flight to go on your well deserved holiday.
You denote by N the total (random) number of planes arriving while you wait and you assume that, for
some λ > 0, N ∼ Poi(λ). Each plane, independently, turns out to be a British Airways plane with
probability p ∈ (0, 1), hence with probability 1 − p it will be a plane from another airline. We write
N = X + Y where X represents the number of British Airways planes and Y the number of planes from
other airlines. You are wondering what might be the joint probability mass function of X and Y .
You recall that the Bernoulli distribution describes binary outcomes with success probability p. So,
every time a plane you observe turns out to be a British Airways plane, you view this as a success and a
failure otherwise.
96
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
You recall that the number of success given the total number of trials follows a Binomial distribution,
so more precisely, in your case you have for n ∈ N
X|N = n ∼ Bin(n, p), and Y |N = n ∼ Bin(n, 1 − p).
Given this information, you try to compute P(X = x, Y = y). For this, it would be really useful to know
N , so let us apply the law of total probability given information on N . For x, y ∈ N ∪ {0}:
∞
X
P(X = x, Y = y) = P(X = x, Y = y|N = n)P(N = n).
n=0
Clearly P(X = x, Y = y|N = n) > 0 ⇔ x + y = n. So, in the sum, we can get rid off all the terms which
result in conditional probabilities being equal to 0.
∞
X
P(X = x, Y = y) = P(X = x, Y = y|N = n)P(N = n)
n=0
X
= P(X = x, Y = y|N = n)P(N = n)
n:x+y=n
97
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
Ry Z
fX,Y (x, v)dv y
H(y, x) −∞ fX,Y (x, v)dv
lim P(Y ≤ y|x ≤ X ≤ x + ϵ) = = = = G(y).
ϵ→0 fX (x) fX (x) −∞ fX (x)
fX,Y (x, y)
g(y) = , for y ∈ R.
fX (x)
The derivations above only work in the case when fX (x) > 0. Let us now state our formal definition:
Definition 14.2.1 (Conditional distribution and conditional density). For two jointly continuous random
variables X, Y , we define the conditional density of Y given X = x as
fX,Y (x, y)
fY |X (y|x) = , (14.2.1)
fX (x)
for all y ∈ R and for all x ∈ R for which fX (x) > 0. The corresponding conditional distribution function
of Y given X = x is then given by
Ry
fX,Y (x, v)dv
FY |X=x (y|x) = −∞ ,
fX (x)
fY |X (y|x) = fY (y),
98
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
We note that the interchange of the integrals can be justified by Tonelli’s theorem, which states that for
non-negative functions the order of the integration can be interchanged. The proof of Tonelli’s theorem is
beyond the scope of this course.
Similarly to the discrete case, we can now define the conditional expectation and formulate the law of
total expectation.
Definition 14.2.4 (Conditional expectation). For two jointly continuous random variables X, Y , we define
the conditional expectation of Y given X = x as
Z ∞ Z ∞
fX,Y (x, y)
E(Y |X = x) = yfY |X (y|x)dy = y dy,
−∞ −∞ fX (x)
provided that fX (x) > 0.
Recall that, in the discrete case, Theorem 14.1.2 implies that for jointly discrete random variables X, Y
with E|Y | < ∞, we have
X
E(Y ) = E(Y |X = x)P(X = x),
x:P(X=x)>0
whenever the sum converges absolutely. The continuous analogue reads as follows:
Theorem 14.2.5 (Law of total expectation). For jointly continuous random variable X, Y with E|Y | < ∞,
we have
Z
E(Y ) = E(Y |X = x)fX (x)dx.
{x:fX (x)>0}
Proof. We use the definition of the expectation, the fact that the marginal density of Y can be obtained by
integrating out the joint density and equation (14.2.1):
Z Z Z
E(Y ) = yfY (y)dy = yfX,Y (x, y)dxdy
Z Z
= yfY |X (y|x)fX (x)dxdy
Z Z
= yfY |X (y|x)dy fX (x)dx
Z
= E(Y |X = x)fX (x)dx,
where we assume that the integrals range over the appropriate values for x and y.
99
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
14.2.1 Examples
Example 14.2.6. Consider two jointly continuous random variables with joint density (for λ > 0):
2 −λy
λ e , for 0 ≤ x ≤ y < ∞,
fX,Y (x, y) =
0, otherwise.
• Find fY |X :
fX,Y (x,y)
Recall that fY |X (y|x) = fX (x) . We compute the marginal density of X first:
Z ∞ Z ∞ ∞
(−1) −λy
fX (x) = fX,Y (x, y)dy = λ2 e−λy dy = λ2 e = λe−λx ,
−∞ x λ y=x
Example 14.2.7. Let ρ ∈ (−1, 1). The standard bivariate normal distribution has joint density given by
1 1 2 2
fX,Y (x, y) = p exp − x − 2ρxy + y
2π 1 − ρ2 2 (1 − ρ2 )
Z ∞
fX (x) = fX,Y (x, y)dy
−∞
Z ∞
1 1 2 2
= p exp − x − 2ρxy + y dy
−∞ 2π 1 − ρ
2 2 (1 − ρ2 )
Z ∞
1 1 2 2 2
= p exp − (y − ρx) + x 1 − ρ dy
−∞ 2π 1 − ρ
2 2 (1 − ρ2 )
Z
1 −x2 /2 ∞ 1 (y − ρx)2
=√ e p exp − dy.
2π −∞ 2π (1 − ρ2 ) 2 (1 − ρ2 )
We observe that the integrand in the above integral is the density of an N(ρx, 1−ρ2 ) random variable
and hence the integral equals 1. Hence
1 2
fX (x) = √ e−x /2 .
2π
I.e. X ∼ N(0, 1) (and also Y ∼ N(0, 1)).
100
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
fX,Y (x, y)
fY |X (y|x) =
fX (x)
1 1 2 2
√ 2
= p exp − x − 2ρxy + y 2πex /2
2π 1 − ρ2 2 (1 − ρ2 )
1 1 2 2
2
= √ p exp − x − 2ρxy + y + x /2
2π 1 − ρ2 2 (1 − ρ2 )
1 1 2 2 2 2
= √ p exp − x − 2ρxy + y − x (1 − ρ )
2π 1 − ρ2 2 (1 − ρ2 )
1 (y − ρx)2
= p exp − .
2π(1 − ρ2 ) 2 (1 − ρ2 )
where we used the law of the total expectation, see Theorem 14.2.5. Note that E(XY |X = x) =
E(xY |X = x) = xE(Y |X = x) = ρx2 , hence
Z ∞ Z ∞
Cov(X, Y ) = ρx2 fX (x)dx = ρ x2 fX (x)dx = ρE(X 2 )
−∞ −∞
= ρVar(X) = ρ.
101
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
So, we have
ρ = E(XY ) − E(X)E(Y ),
which, with our findings above, implies the following important result: Assume that X, Y follow a
bivariate (standard) normal distribution. Then X and Y are independent if and only if E(XY ) =
E(X)E(Y ).
Warning: As soon as you drop the assumption that you are dealing with jointly normal random
variables, then we only know that if we assume that they are independent, then the product formula
for the expectations holds. However, if we have only verified that the product formula for the expec-
tations holds, then that does not imply in general independence of the random variables. We will
illustrate this in the following remark and example.
Remark 14.2.8. • If (X, Y ) is bivariate normal and Cov(X, Y ) = 0 ⇒ X, Y are independent.
• However, if X and Y follow a univariate normal distribution and Cov(X, Y ) = 0 ̸⇒ X, Y are
independent.
Example 14.2.9. Let X ∼ N(0, 1). Let Z be a discrete random variable, independent of X with P(Z =
−1) = P(Z = 1) = 21 . Let Y := Z · X. We want to show that
1. Y ∼ N(0, 1),
2. Cov(X, Y ) = 0,
3. X and Y are not independent.
1. Y ∼ N(0, 1):
Let y ∈ R. Then, using the law of total probability and the independence of Z and X, we have
independence of X,Z
Cov(X, Y ) = E(XY ) − E(X)E(Y ) = E(X 2 Z) = E(X 2 )E(Z) = 1 · 0 = 0.
As a side remark, we note that the sum of X and Y is not normally distributed (and not even continuous!):
102
A. E. D. Veraart MATH40005: Probability and Statistics Autumn 2023
103
Bibliography
Anderson, D. F., Seppäläinen, T. & Valkó, B. (2018), Introduction to probability, Cambridge Mathematical
Textbooks, Cambridge University Press, Cambridge.
Blitzstein, J. K. & Hwang, J. (2019), Introduction to probability, Texts in Statistical Science Series, CRC
Press, Boca Raton, FL. Second edition.
Feller, W. (1957), An introduction to probability theory and its applications. Vol. I, John Wiley and Sons,
Inc., New York; Chapman and Hall, Ltd., London. 2nd ed.
Grimmett, G. & Welsh, D. (1986), Probability: an introduction, Oxford Science Publications, The Claren-
don Press, Oxford University Press, New York.
Hájek, A. (2012), Interpretations of probability, in E. N. Zalta, ed., ‘The Stanford Encyclopedia of Philos-
ophy’, Winter 2012 edn, Metaphysics Research Lab, Stanford University.
Proschan, M. A. & Shaw, P. A. (2016), Essentials of probability theory for statisticians, Chapman &
Hall/CRC Texts in Statistical Science Series, CRC Press, Boca Raton, FL.
Ross, S. (2014), A first course in probability, ninth edn, Macmillan Co., New York; Collier Macmillan Ltd.,
London.
Spiegelhalter, D., Pearson, M. & Short, I. (2011), ‘Visualizing uncertainty about the future’, Science
333(6048), 1393–1400.
104