Discrete random variables
October 19, 2023
1 / 38
Objectives
1 Understand random variables
2 For discrete random variables
a Determine probabilities from probability mass
functions and the reverse
b Determine probabilities from cumulative
distribution functions and cumulative
distribution functions from probability mass
functions, and the reverse
2 / 38
Intro
• Sample space and events are basic
components of probability
• Similar to numbers in calculus
• Study the relations between numbers we
use functions
• In probability we use random variables
3 / 38
Definition
A random variable X defined on a sample space
Ω is a quantity that is calculated by the outcomes
- a function of outcomes
4 / 38
Example
• Toss a coin three times
• X be the number of times that tails appear
• Sample space Ω =
{HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}
• X(HHH) = 0, X(HHT) = 1 . . .
5 / 38
w HHH HHT HTH HTT THH THT TTH TTT
X(w) 0 1 1 2 1 2 2 3
All possible values of X are 0, 1, 2, 3. We say Range(X) =
{0, 1, 2, 3}
1
P(X = 0) = P(there is no tail) = P(HHH) =
8
3
P(X = 1) = P(there is 1 tail) = P({HHT, HTH, THH}) =
8
6 / 38
Example
• Tossing a fair coin until a Head appear.
The sample space is
Ω = {H, TH, TTH, TTTH, . . . }
• X: the number of tossing
• Range(X) = {1, 2, 3, . . . ...}
• X = 1 if and only if the first coin turns head
so P(X = 1) = P(first coin turns H) = 0.5
7 / 38
Question
Evaluate
P(X = 2)
and
P(1 < X ≤ 4)
8 / 38
Types of RV
Based on range of the random variable X
• If the set of possible values of X is finite or
countable like {0, 1, 2, 3}, {1, 2, . . . } then
X is called discrete RV
• If the set of possible values of X is
uncountable (like the interval [a, b],
[a, ∞)) then X is called continuous RV
9 / 38
Probability associated with a
random variable X
P(X = a), P(X ≥ a), P(X > a),
P(X ≤ b), P(X < b),
P(a ≤ X ≤ b), P(a < X ≤ b),
P(a ≤ X < b), P(a < X < b)
10 / 38
Cumulative distribution function
(cdf)
cdf of F(.) of the random variable X is a function
defined by
F(b) = P(X ≤ b)
is the probability that X takes on values less than
or equal to b
11 / 38
Use cdf to answer questions about a random variable
P(X ≤ b) = F(b)
P(X < b) = lim P(X ≤ b − h) = lim F(x) = F(b−)
h→0+ x→b−
P(X > a) = 1 − P(X ≤ a) = 1 − F(a)
P(a < X ≤ b) = P(X ≤ b) − P(X ≤ a) = F(b) − F(a)
P(a ≤ X ≤ b) = F(b) − F(a−)
P(a < X < b) = F(b−) − F(a)
12 / 38
Discrete Random Variables
Random variable can take on at most count-
able number of possible values
Range(X) = {x1, x2, . . . }
13 / 38
Probability mass function
The probability mass function (p.m.f) of the dis-
crete random variableX is defined as
p(xi) = P(X = xi) for all xi ∈ Range(X)
the probability that the value of X is equal to xi
14 / 38
Example
Roll two fair dice then the sample space is
Ω = {(1, 1, ), . . . , (6, 6)} = {(i, j) : 1 ≤ i, j ≤ 6}
Let X be the largest of numbers on two dice, i.e
if the rolling result is (i, j) then
X(i, j) = max(i, j)
15 / 38
Table values of X
16 / 38
All possible values of X is
Range(X) = {1, 2, 3, 4, 5, 6}
so X is a discrete random variable.
In order to determine the pmf of X, we need to
find all the probabilities
P(X = 1), P(X = 2), . . . , P(X = 6)
17 / 38
X = 1 if and only if the outcome is (1, 1). So
P(X = 1) = P((1, 1)) = 1/36
X = 2 if and only if the outcomes is one of
(1, 2), (2, 2), (2, 2). So
P(X = 2) = P({(1, 2), (2, 1), (2, 2)})
= P((1, 2)) + P((2, 1)) + P((2, 2) = 3/36
18 / 38
Similar, we have P(X = 3) = 5/36, P(X = 4) =
7/36, P(X = 5) = 9/36, P(X = 6) = 11/36.
We can summary p.m.f of X in the p.m.f table
x 1 2 3 4 5 6
1 3 5 7 9 11
P(X = x) 36 36 36 36 36 36
19 / 38
Similar, we have P(X = 3) = 5/36, P(X = 4) =
7/36, P(X = 5) = 9/36, P(X = 6) = 11/36.
We can summary p.m.f of X in the p.m.f table
x 1 2 3 4 5 6
1 3 5 7 9 11
P(X = x) 36 36 36 36 36 36
19 / 38
Illustration to calculate pmf
For each possible value x, we collect all the outcomes that
give rise to X = x and add their probabilities to obtain
pX (x) = P(X = x). 20 / 38
One can use p.m.f of the discrete random vari-
able X to answer any question of X such as
P(1 < X < 4) = P(X = 2 or X = 3)
= P(X = 2) + P(X = 3) = 3/36 + 5/36
using additive rule for disjoin set
P(A ∪ B) = P(A) + P(B) if A ∩ B = ∅
for A = {X = 2}, B = {X = 3}
21 / 38
Practice
Probability mass function of discrete random vari-
able X is
x -2 -1 0 1 2
p(x) = P(X = x) 1/8 2/8 2/8 2/8 1/8
Determine
1 P(X ≤ −1 or X = 2)
2 P(−1 ≤ X ≤ 1)
22 / 38
Practice
A shipment of 20 similar laptop computers to a
retail outlet contains 3 that are defective. If a
school makes a random purchase of 2 of these
computers, find the probability mass function
(p.m.f) for the number of defectives.
23 / 38
Practice
An urn contains 11 balls, 3 white, 3 red, and 5
blue balls. Take out 3 balls at random, without
replacement. You win $1 for each red ball you
select and lose a $1 for each white ball you se-
lect. Determine the p.m.f of your loss/profit X.
24 / 38
Properties of pmf
• X is discrete
→ Range(X) = {x1, . . . , xn . . . }
• p(xi) = P(X = Xxi) ≥ 0
• P(X ∈ A) = p(xi)
xi ∈A
• Normalization
∞
X
P(−∞ < X < ∞) = 1 ⇒ p(xi) = 1
i=1 25 / 38
Properties of pmf
• X is discrete
→ Range(X) = {x1, . . . , xn . . . }
• p(xi) = P(X = Xxi) ≥ 0
• P(X ∈ A) = p(xi)
xi ∈A
• Normalization
∞
X
P(−∞ < X < ∞) = 1 ⇒ p(xi) = 1
i=1 25 / 38
Properties of pmf
• X is discrete
→ Range(X) = {x1, . . . , xn . . . }
• p(xi) = P(X = Xxi) ≥ 0
• P(X ∈ A) = p(xi)
xi ∈A
• Normalization
∞
X
P(−∞ < X < ∞) = 1 ⇒ p(xi) = 1
i=1 25 / 38
Example
Suppose X has 3 values 1, 2, 3 and
1 1
p(1) = , p(2) =
2 3
then what is p(3)?
p(3) = 1 − p(1) − p(2) = 1/6.
26 / 38
Example
Suppose X has 3 values 1, 2, 3 and
1 1
p(1) = , p(2) =
2 3
then what is p(3)?
p(3) = 1 − p(1) − p(2) = 1/6.
26 / 38
Graph of p(x)
27 / 38
Practice
Suppose that the pmf of random variable X is
given by
p(x) = c(x + 5), x = 0, 1, 2, 3, 4
Find c and P(0 < X < 2.5).
28 / 38
Cumulative distribution function
(cdf)
Probability that X does not exceed a given value
X
F(b) = P(X ≤ b) = P(X = xi)
xi ≤b
29 / 38
Example
Suppose that pmf of X is given by p(1) = 21 , p(2) =
1 1
3 , p(3) = 6 then
F(0.5) = P(X ≤ 0.5) = 0
5
F(2.4) = P(X ≤ 2.4) = P(X = 1)+P(X = 2) =
6
30 / 38
The formula of the cdf of X is
0, x < 1
1, 1 ≤ x < 2
F(x) = 25
6, 2 ≤ x < 3
1, x ≥ 3
31 / 38
Graph of F(x)
Remark
Jump size at 1 is P(X = 1), ... 32 / 38
Example
Determine the p.m.f of X from the c.d.f
0 if x < −2
0.2 if − 2 ≤ x < 0
F(x) =
0.7 if 0 ≤ x < 2
if x ≥ 2
1
33 / 38
Solution
Graph of F(x) is
P(X = a) = F(a)−F(a−) is nonzero at the points −2, 0, 2.
The p.m.f at each point is the change (jump size) of c.d.f
at the point 34 / 38
p.m.f of X is given by
p(−2) = P(X = −2) = F(−2) − F(−2−)
= 0.2 − 0 = 0.2
p(0) = P(X = 0) = F(0) − F(0−)
= 0.7 − 0.2 = 0.5
p(2) = P(X = 2) = F(2) − F(2−)
= 1 − 0.7 = 0.3
35 / 38
Properties of cdf of a discrete RV
• lim F(x) = 0 and lim F(x) = 1
x→−∞ x→∞
• FX has a piecewise constant and
staircase-like form.
36 / 38
Practice
c.d.f of discrete random variable X is given by
0
if x < 1
F(x) = 0.7 if 1 ≤ x < 3
1 if x ≥ 3
Compute
1 P(X ≤ 2) and P(X > 2)
2 P(1 ≤ X ≤ 2)
37 / 38
Keywords
• pmf of a discrete RV with range {x1 , . . . , xn , . . . }
p(xi ) = P(X = xi )
• 0 ≤ p(xi) ≤ 1
•
P
p(xi) = 1
• P(X ∈ A) = x ∈A p(xi)
P
i
• cdf X
F(x) = P(X ≤ x) = p(xi )
xi ≤x
38 / 38