Lecture 9 - Discrete Structure - Discrete Probability - Part 1
Lecture 9 - Discrete Structure - Discrete Probability - Part 1
CS103
Chapter 6
Discrete Probability – Part 1
2
Discrete Probability
• Everything you have learned about counting constitutes the basis for
• In the following, we will use the notion of experiment for a procedure that
yields one of a given set of possible (atomic and disjoint) outcomes.
• This set of possible outcomes is called the sample space of the experiment.
• An event is a subset of the sample space.
3
Experiment – Outcomes – Random Variable
4
Outcomes – Probabilities – Mathematical Notation
5
Probability Mass function - PMF
6
Discrete Probability
• If all outcomes in the sample space are equally likely, the following definition
of probability applies:
𝐸
𝑝 𝐸 = .
|𝑆|
• Probability values range from 0 (for an event that will never happen) to 1 (for
an event that will always happen whenever the experiment is carried out).
7
Discrete Probability
Example I:
• A vase contains four blue balls and five red balls. What is the probability
that a ball chosen from the vase is blue?
Sol.
• There are nine possible outcomes, and the event “blue ball is chosen”
comprises four of these outcomes.
• 4
Therefore, the probability of this event is or approximately 44.44%.
9
8
Complementary Events
𝑝 −𝐸 = 1 – 𝑝 𝐸 .
9
Complementary Events
Example I:
A sequence of 10 bits is randomly generated. What is the probability that at least
one of these bits is zero?
Sol.
• There are 210 = 1024 possible outcomes of generating such a sequence. The
event – 𝐸, “none of the bits is zero”, includes only one of these outcomes, namely
the sequence 1111111111.
• Therefore,
1
𝑝 −𝐸 =
1024
• Now, 𝑝(𝐸) can easily be computed as,
1 1023
𝑝 𝐸 = 1 – 𝑝 −𝐸 = 1 – =
1024 1024
10
Complementary Events
Example II:
• A random number is chosen from 1 to 50. Calculate the probability of not choosing a
perfect square.
Sol.
• Let event – 𝐸 be the event of choosing a perfect square. The sample space is given as
follows:
• – 𝐸 = {1, 4, 9, 16, 25, 36, 49}
• Total number of outcomes = 50
• Then 𝐸 7
𝑝 −𝐸 = = = 0.14,
|𝑆| 50
so,
7
𝑝 𝐸 =1 − = 1 − 0.14 = 0.86 or 86%
50
11
Discrete Probability
12
Discrete Probability
Example:
What is the probability of a positive integer selected at random from the set 𝑆 of
positive integers not exceeding 100 to be divisible by 2 or 5?
Sol.
• 𝐸2 = {2, 4, 6, … , 100}
• 𝐸2 = 50
• 𝑝 𝐸2 = 𝐸2 = 50 = 0.5 13
𝑆 100
Discrete Probability
• 𝐸5 = {5, 10, 15, … , 100}
• 𝐸5 = 20
• 𝑝 𝐸5 = 𝐸5 = 20 = 0.2
𝑆 100
• 𝐸2 ∩ 𝐸5 = 10
• 𝑝 𝐸2 ∩ 𝐸5 = 𝐸2∩ 𝐸5 = 10 = 0.1
𝑆 100
• 𝑝 𝐸2 ∪ 𝐸5 = 𝑝 𝐸2 + 𝑝 𝐸5 − 𝑝 𝐸2 ∩ 𝐸5
1 2
𝑝 𝑠1 = 𝑝 𝑠2 = 𝑝 𝑠4 = 𝑝 𝑠 5 = 𝑝 𝑠6 = , 𝑝(𝑠3) =
7 7
15
PMF of Biased / Loaded Die
16
Discrete Probability
Example II: For the biased die from the previous example, what is the probability that an odd
number appears when we roll the die?
Sol.
𝑝 𝐸𝑜𝑑𝑑 = 𝑝 𝑠
𝑠∈E𝑜𝑑𝑑
= 𝑝 𝑠1 + 𝑝 𝑠3 + 𝑝 𝑠5
1 2 1 4
= + + = = 57.14%
7 7 7 7
17
Conditional Probability
• If we toss a coin three times, what is the probability that an odd number of tails
appears (event 𝐸), if the first toss is a tail (event 𝐹)?
Sol.
• If the first toss is a tail, the possible sequences are 𝑇𝑇𝑇, 𝑇𝑇𝐻, 𝑇𝐻𝑇, and 𝑇𝐻𝐻.
• For any outcome of 𝐸 to occur under the condition that 𝐹 also occurs, this outcome must
also be in
𝑬∩𝑭
Definition:
𝒑 𝑬∩𝑭
𝒑 𝑬|𝑭 =
𝒑 𝑭
19
Conditional Probability
Example: What is the probability of a random bit string of length four
to contain at least two consecutive 𝟎s, given that its first bit is a 𝟎?
Sol.
𝐸: “bit string contains at least two consecutive 0s”
𝐹: “first bit of the string is a 0”
We know the formula:
𝑝 𝐸∩𝐹
𝑝 𝐸|𝐹 = .
𝑝(𝐹)
𝐸∩𝐹 5
𝑝 𝐸∩𝐹 = =
𝑆 16
𝐹 8
𝑝 𝐹 =
=
𝑆 16
𝑝 𝐸∩𝐹 5/16 5
𝑝 𝐸|𝐹 = = = = 0.625
𝑝(𝐹) 8/16 8
20
Independence
Definition:
21
Independence
Example:
• Suppose 𝐸 is the event of rolling an even number with an unbiased die.
• 𝐹 is the event that the resulting number is divisible by three.
• Are events 𝑬 and 𝑭 independent?
Sol.
3 1
𝐸 = 2, 4, 6 𝑠𝑜, 𝑝 𝐸 = =
6 2
2 1
𝐹 = 3, 6 𝑠𝑜, 𝑝 𝐹 = =
6 3
1
𝐸∩𝐹 = 6 𝑠𝑜, 𝑝 𝐸∩𝐹 =
6
Then, 𝑝 𝐸 ∩ 𝐹 = 𝑝(𝐸)𝑝(𝐹)
23