IE 5004 Lecture 2
IE 5004 Lecture 2
IE 5004 Lecture 2
He Shuangchi
Suppose that two gamblers, Tom and Jerry, are rolling a fair die.
If the outcome is 1, 2, or 3, Tom wins one dollar.
If the outcome is 4, 5, or 6, Jerry wins one dollar.
Let X be Tom’s gain of a particular run of the game. It is either 1 dollar
or −1 dollar, depending on the outcome of this run.
X (1) = X (2) = X (3) = 1
X (4) = X (5) = X (6) = −1
Question
Let Y be Jerry’s gain of that run. What is Y (1), . . . , Y (6)?
Let X be the random variable that is defined as the sum of two fair dice.
What is the set {X = 2}? {X = 2} = {(1, 1)} and
1
P[X = 2] = P[{(1, 1)}] =
36
What is the set {X = 5}? {X = 5} = {(1, 4), (2, 3), (3, 2), (4, 1)} and
4
P[X = 5] = P[{(1, 4), (2, 3), (3, 2), (4, 1)}] =
36
Example
Suppose that I am taking a driving test to obtain my driver’s license. If I
fail in the test, I will take the test again and again until I pass it. Once I
pass it, I can have the license. Let us consider the results of my tests until
I get the license.
The result of each test can be pass or fail, so the sample space is
Example
To obtain my driver’s license. I also need to pass a theory test. The test
has 25 questions. I need to answer at least 20 questions correctly to pass
the exam. Suppose that for each question, I can give the right answer with
probability p and the correctness of different answers are independent. Let
Y be the number of correct answers.
Example
Suppose that I am a farmer and have a cow farm. Each day the cows
produce some milk and I sell milk at two dollars per liter. On each day, the
produced milk is equally random between 4500 and 5000 liters. Let us
consider the amount of milk produced tomorrow.
Ω = [4500, 5000]
Definition
If a random variable can only take countably many values, it is a discrete
random variable.
Definition
If a random variable X can take uncountably many values and
P[X = a] = 0 for each a ∈ R, it is a continuous random variable.
P[X = k] = P[The first k − 1 tests all fail and the kth test passes]
= (1 − p)k−1 p
Definition
The probability mass function of a discrete random variable X is defined
for x ∈ R by
p(x) = P[X = x]
0.2
p(x)
0.1
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
x
Figure: p = 0.2
p(x)
0.1
0
0 5 10 15 20 25
x
Figure: p = 0.8
25 n
p(n) = P[Y = n] = p (1 − p)25−n
n
IE5004 Discrete Random Variables 15 / 45
Cumulative distribution function
Exercise
Suppose the probability mass function of X is given by
x 1 2 4 8 16
p(x) 0.05 0.10 0.35 0.40 0.10
x 1 2 4 8 16
p(x) 0.05 0.10 0.35 0.40 0.10
0 x <1
0.05 1≤x <2
0.15 2≤x <4
F (x) =
0.5 4≤x <8
0.9 8 ≤ x < 16
1 x ≥ 16
Exercise
Prove the fourth property.
Theorem
Let X1 , X2 , . . . be an infinite sequence of independent, identically
distributed (iid) random variables with expected value
E[X1 ] = E[X2 ] = · · · = µ
Let
X1 + X2 + · · · + Xn
X̄n =
n
be the sample mean of the first n random variables. Then,
X̄n → µ as n → ∞
The SLLN applies to any random variable that has a finite expected
value (i.e., µ ̸= ±∞).
Hence,
E[I ] = 1 · P[A] + 0 · (1 − P[A]) = P[A]
Then,
E[I1 ] = E[I2 ] = · · · = P[A]
Note that
I1 + I2 + · · · + In
I¯n =
n
is the relative frequency that A occurs for n independent trials. The SLLN
implies that
I¯n → P[A] as n → ∞
In other words, P[A] is the long-run relative frequency that A occurs.
Proposition
Let X be a discrete random variable that has a set of possible values D
and probability mass function p(x), then the expected value of any
function h(X ) is given by
X
E[h(X )] = h(x)p(x)
x∈D
Definition
Let µ = E[X ] be the expected value of X and h(x) = (x − µ)2 . Then
X
V (X ) = E[h(X )] = E[(X − µ)2 ] = (x − µ)2 p(x)
x∈D
p(x)
0.3
0.2
0.1
0
−6 −4 −2 0 2 4 6
x
0.5
0.4
p(x)
0.3
0.2
0.1
0
−6 −4 −2 0 2 4 6
x
Figure: V (X ) = 0.6 in the first plot while V (X ) = 11.85 in the second one.
V (X + Y ) = V (X ) + V (Y )
Exercise
Prove the shortcut formula when X is a discrete random variable.
X (S) = 1 and X (F ) = 0
Definition
Any random variable whose only possible values are 0 or 1 is called a
Bernoulli random variable.
Expected value:
E[X ] = 1 · p + 0 · (1 − p) = p
Variance:
V (X ) = E[(X − p)2 ]
= (1 − p)2 · p + (0 − p)2 · (1 − p)
= p(1 − p)
Suppose that we repeat the Bernoulli trial many times and these trials are
independent. Let X be the number of trials until we get the first success.
Then, X is a geometric random variable.
Probability mass function:
Expected value:
∞
X 1
E[X ] = k · (1 − p)k−1 p =
p
k=1
Variance:
1−p
V (X ) =
p2
Example
I am taking a driving test to obtain my driver’s license. If I fail, I will take
the test again and again until I pass it. Suppose that the result of each
test is independent and I can pass each test with probability 0 < p < 1.
Question
You have repeated m independent trials with all failures. What is the
probability that you need more than n extra trials before getting a success?
Y = X1 + · · · + Xn
Example
To obtain my driver’s license. I need to pass a theory test. The test has 25
questions. Suppose that for each question, I can give the right answer with
probability p and the correctness of all answers are independent one
another. Let Y be the number of correct answers.
Exercise
The color of one’s eyes is determined by a single pair of genes, with the
gene for brown eyes being dominant over the one for blue eyes. This
means that an individual having two blue-eyed genes will have blue eyes,
while one having either two brown-eyed genes or one brown-eyed and one
blue-eyed gene will have brown eyes. When two people mate, the resulting
offspring receives one randomly chosen gene from each of its parents’ gene
pair. If the eldest child of a pair of brown-eyed parents has blue eyes, what
is the probability that exactly two of the four other children (none of
whom is a twin) of this couple also have blue eyes?
Because the eldest child has blue eyes, both parents must have one
blue-eyed gene and one brown-eyed gene.
The probability that an offspring has blue eyes is 0.5 × 0.5 = 0.25.
Because each of the other four children will have blue eyes with
probability 0.25, the probability that exactly two have blue eyes is
4 27
× 0.252 × 0.752 =
2 128
0.4 0.25
p = 0.1, n = 10 p = 0.5, n = 10
0.35
p = 0.1, n = 20 0.2 p = 0.5, n = 20
0.3
0.25 0.15
0.2
0.15 0.1
0.1
0.05
0.05
0 0
0 5 10 15 20 0 5 10 15 20
0.4
p = 0.9, n = 10
0.35
p = 0.9, n = 20
0.3
0.25
0.2
0.15
0.1
0.05
0
0 5 10 15 20
λk
n k n! λ n−k
P[Y = k] = p (1 − p)n−k = 1 −
k k!(n − k)! nk n
n(n − 1) · · · (n − k + 1) λ k λ n λ −k
= 1 − 1 −
| n{zk } k! | {zn } | {zn }
→1 →e −λ →1
λk
→ e −λ as n → ∞
k!
Exercise
The probability that a traffic light fails in a day is 1/3650. Suppose that
there are 10,000 lights installed in Singapore. What is the probability of no
failure within a day?
λk −λ
10000 k
P[Y = k] = p (1 − p)10000−k ≈ e
k k!
4 /3650
Hence, P[Y = 0] = e −10 = 0.0646
Definition
A discrete random variable X is called a Poisson random variable with
parameter λ > 0 if its probability mass function is given by
λk −λ
p(k) = P[X = k] = e for k = 0, 1, . . .
k!
Exercise
P∞
Verify that k=0 p(k) = 1.
E[X ] = λ
V (X ) = λ
IE5004 Discrete Random Variables 42 / 45
Poisson PMF
0.7 0.35
0.5 0.25
0.4 0.2
0.3 0.15
0.2 0.1
0.1 0.05
0 0
0 2 4 6 8 10 0 5 10 15
0.14
λ = 10
0.12
0.1
0.08
0.06
0.04
0.02
0
0 5 10 15 20 25
0.35 0.35
binomial n = 10, p = 0.2 binomial n = 100, p = 0.02
0.3 0.3
Poisson λ = 2 Poisson λ = 2
0.25 0.25
0.2 0.2
0.15 0.15
0.1 0.1
0.05 0.05
0 0
0 2 4 6 8 10 0 2 4 6 8 10
0.2 0.2
0.18 binomial n = 50, p = 0.2 0.18 binomial n = 500, p = 0.02
0.14 0.14
0.12 0.12
0.1 0.1
0.08 0.08
0.06 0.06
0.04 0.04
0.02 0.02
0 0
0 5 10 15 20 0 5 10 15 20
Reading assignment:
Read Chapters 4.1–4.7, 4.8.1
Study Chapter 4.9 on your own
Exercise problems:
4.21, 4.35, 4.38, 4.40, 4.49, 4.57, 4.63