CE 93 Engineering Data Analysis
Topic 05: Conditional Probability
Mohamad M. Hallal
Conditional Probability: Motivation 1
• Let 𝐸 represnet the event that a student is enrolled in CE 93, 𝐶 represnet
the event a student is a Civil Engineering major, and 𝑁 represnet the event
that a student is neither enrolled in CE 93 nor a Civil Engineering major.
Suppose 𝑃 𝐸 = 0.10, 𝑃 𝐶 = 0.15, and 𝑃 𝑁 = 0.83.
• Based on the Venn Diagram, if a student 𝑺
is enrolled in CE 93, are they more likely 𝑬
to be a Civil Engineering major?
𝑪
2
Conditional Probability: Motivation 2
• A sample space contains all the possible outcomes
– Sometimes, we obtain additional information that tells us that the outcome is from a certain part of
the sample space
• Probability may change as additional information is gathered
– This is conditional probability
3
Conditional Probability: Motivation 2
0
1 48’
53’
0’
9’
FT’ 0
12
2
4
Conditional Probability: Motivation 3
• In 1999, Sally Clark was convicted of killing her two children, who both died a few
months old. An expert witness testified that the probability of a child dying due to
natural causes (known as sudden infant death syndrome SIDS) is 1 in 8,500, and
hence, the probability of two dying from SIDS is 1 in 73,000,000. The prosecution
used this low probability to argue that she was almost certainly guilty of murder.
• After the involvement of statisticians who highlighted the misuse of probability,
Sally Clark's conviction was overturned in 2003.
• Can you tell what was wrong with the original arguments?
5
Learning Objectives
1. Define conditional probability, its notation, and provide examples
2. Compute conditional probabilities using the definition of conditional probability
3. Compute the probability of the intersection of two events using the multiplication rule
4. Recognize and apply the concept of independence to determine if events are
independent and to compute the probability of their intersection
5. Apply the Law of Total Probability to compute the probability of an event
6. Apply Bayes' Theorem to find conditional probabilities in complex scenarios
7. Draw and use tree diagrams to visualize and calculate conditional probabilities
8. Translate real-world problems into conditional probability statements and solve them
using appropriate techniques
6
Conditional Probability
7
Conditional Probability
• For any events A and B with 𝑃 𝐵 > 0, the conditional probability of A given B is:
=
𝑺
𝑩 𝑩
– Probability of A given B occurred 𝑨
– 𝑃 𝐴 if B
– 𝑃 𝐴 conditional on B
– 𝑃 𝐴 given the outcome is in the restricted sample space associated with B
8
Learning Objective # 1
Motivation Example: Solution by Formula
• Let 𝐸 represnet the event that a student is enrolled in CE 93, 𝐶 represnet
the event a student is a Civil Engineering major, and 𝑁 represnet the event
that a student is neither enrolled in CE 93 nor a Civil Engineering major.
Suppose 𝑃 𝐸 = 0.10, 𝑃 𝐶 = 0.15, and 𝑃 𝑁 = 0.83.
– 𝑃 𝐸 ∩ 𝐶 = 0.08 from 04_Probability_Fundamentals slides
• If a student is enrolled in CE 93, what is 𝑺 𝑬
the probability they are a Civil major?
𝑪
9
Learning Objective # 2
Conditional Probability: Example
• A leak is equally likely to occur anywhere along a 100 km pipeline. Let A be the event
that a leak occurs between 20 and 60 km. Let B be the event that a leak occurs between
0 and 30 km. If we know a leak occurred between 20 and 60 km (i.e., A occurred), what
is the probability it occurred between 0 and 30 km (i.e., B also occurred)?
100 km
0 20 30 60 100
20 km 10 km 40 km
30 km
A
B
10
Learning Objective # 2
Conditional Probability: Example
• If we know a leak occurred between 0 and 30 km (i.e., B occurred), what is the
probability it occurred between 20 and 60 km (i.e., A also occurred)?
100 km
0 20 30 60 100
20 km 10 km 30 km
A
B
11
Learning Objective # 2
Conditional Probability
• Conditional probabilities are a common source of confusion
• Confusion of the inverse: confusing the condition
– 𝑃 𝐴𝐵 ≠𝑃 𝐵𝐴
– “Most pilots are men” is NOT the same as “most men are pilots”
– “Probability that the test is positive if a person has COVID” is NOT the same as “Probability that a
person has COVID if the test is positive”
• Confusing the condition with “and”
– 𝑃 𝐴 𝐵 ≠ 𝑃(𝐴 ∩ 𝐵)
– “Being a man given that a person is a pilot” is NOT the same as “being a man and a pilot”
– “Probability that a person has COVID if the test is positive” versus “Probability that a person has
COVID and the test is positive”
12
Multiplication Rule
13
Multiplication Rule
• If we rearrange the equation of conditional probability, we obtain the
multiplication rule for any two events A and B :
𝑃 𝐴∩𝐵
𝑃 𝐴𝐵 = →
𝑃 𝐵
• We can also write:
𝑃 𝐵∩𝐴
𝑃 𝐵𝐴 = →
𝑃 𝐴
14
Multiplication Rule: Example Multiplication Rule: 𝑃 𝐴 ∩ 𝐵 = 𝑃 𝐴 𝐵 × 𝑃 𝐵
• A town relies on two sources of water: rainfall and groundwater. Each year, there is a
30% chance of a rainfall shortage (R), and a 10% chance of a groundwater shortage
(G). Further, if there is a rainfall shortage, the likelihood of a groundwater shortage
increases to 20%. What is the probability that there is a shortage in both sources?
• If there is a groundwater shortage (G), what is the probability that there is also a
rainfall shortage (R)?
15
Learning Objective # 3
Independence
16
Independence
• In all of the previous examples, knowing that an event has occurred
changed the probability that another event occurs
– The events were related
• Conditional probabilities reflect that certain events may be related, such
that knowing one event has occurred influences the probability that
another event occurs
• Sometimes, knowing that one event has occurred does not change the
probability that another event occurs
– In this case, we say the events are independent (unrelated)
17
Independence
• Independence of events is sometimes obvious:
– Tossing a coin twice and getting H on the first flip and H on the second flip
– Rolling a die twice and getting an even number on the first roll and 2 on the second roll
– The probability of an earthquake happening given it is a Monday
• However, independence of events is not always obvious
• That’s why we check for independence with probabilities
18
Independence
• Two events 𝐴 and 𝐵 are independent if knowing that one occurs does
not affect the probability of the other occurring:
𝐴 and 𝐵 independent ⟺
• Then, from the multiplication rule: 𝑃 𝐴 ∩ 𝐵 = 𝑃 𝐴 𝐵 × 𝑃 𝐵 , we can also
say that two events 𝐴 and 𝐵 are independent if:
𝐴 and 𝐵 independent ⟺
19
Independence
• If 𝐴 and 𝐵 are independent, then the following pairs of events are also
independent:
– 𝐴 and 𝐵𝑐
– 𝐴𝑐 and 𝐵
– 𝐴𝑐 and 𝐵𝑐
𝐴 and 𝐵 independent ⟺ 𝐴 and 𝐵𝑐 independent ⟺ 𝐴𝑐 and 𝐵 independent ⟺ 𝐴𝑐 and 𝐵𝑐 independent
20
Independence
• How do independent events look on a Venn diagram?
𝐴 and 𝐵 are independent if: 𝑃 𝐴 ∩ 𝐵 = 𝑃 𝐴 × 𝑃 𝐵
A. B. Open the iClicker Student Mobile App
Or
Go to the iClicker Web App ([Link])
Click on CE 93 & Join
C. D. E.
21
Independent vs. Mutually Exclusive Events
• If two events 𝐴 and 𝐵 are mutually exclusive with positive probability,
they cannot be independent
– Let’s say 𝑃 𝐴 = 0.5 and 𝑃 𝐵 = 0.2, where 𝐴 and 𝐵 are mutually exclusive
– If 𝐴 occurred, what is the probability that 𝐵 occurs?
– Can also check for independence using 𝑃 𝐴 ∩ 𝐵 ≟ 𝑃(𝐴) × 𝑃 𝐵
• What if one of the events has a probability of zero?
– If either 𝑃 𝐴 = 0 or 𝑃 𝐵 = 0, then 𝐴 and 𝐵 are independent
22
Independence: Example 𝐴 𝑎𝑛𝑑 𝐵 𝑖𝑛𝑑𝑒𝑝𝑒𝑛𝑑𝑒𝑛𝑡 ⇔ 𝑃 𝐴 ∩ 𝐵 = 𝑃 𝐴 × 𝑃(𝐵)
• Let 𝐸 represnet the event that a student is enrolled in CE 93, 𝐶 represnet
the event a student is a Civil Engineering major, and 𝑁 represnet the event
that a student is neither enrolled in CE 93 nor a Civil Engineering major.
Suppose 𝑃 𝐸 = 0.10, 𝑃 𝐶 = 0.15, and 𝑃 𝑁 = 0.83.
– 𝑃 𝐸 ∩ 𝐶 = 0.08 from 04_Probability_Fundamentals slides
• Are the events enrolled in CE 93 and 𝑺 𝑬
being a Civil major independent?
𝑪
23
Learning Objective # 4
Conditional Probability: Motivation 3
• In 1999, Sally Clark was convicted of killing her two children, who both died a few
month old. An expert witness testified that the probability of a child dying due to
natural causes (known as sudden infant death syndrome SIDS) is 1 in 8,500, and
hence, the probability of two dying from SIDS is 1 in 73,000,000. The prosecution
used this low probability to argue that she was almost certainly guilty of murder.
• After the involvement of statisticians who highlighted the misuse of probability,
Sally Clark's conviction was overturned in 2003.
• Can you tell what was wrong with the original arguments?
24
Law of Total Probability
25
Law of Total Probability: Motivation
• Let 𝐸 represnet the event that a student is enrolled in CE 93 and 𝐶 represnet
the event a student is a Civil Engineering major. We want to calculate the
probability of event 𝐸. What information do you need?
𝑬 𝑺
𝑪
26
Law of Total Probability
• If 𝐴1 , 𝐴2 , … , 𝐴𝑛 are a partition (mutually exclusive AND exhaustive), then
the probability of any event 𝐵 is given by:
𝑛
𝑃 𝐵 = 𝑃 𝐵 ∩ 𝐴1 + ⋯ + 𝑃 𝐵 ∩ 𝐴𝑛 = 𝑃 𝐵 𝐴1 𝑃 𝐴1 + ⋯ + 𝑃 𝐵 𝐴𝑛 𝑃 𝐴𝑛 = 𝑃 𝐵 𝐴𝑖 𝑃 𝐴𝑖
𝑖=1
𝑩
𝑺
• 𝐴1 , 𝐴2 , 𝐴3 , 𝐴4 divide 𝐵 into mutually exclusive 𝐴1 𝐴3 𝐴4
and exhaustive subsets. Their union is 𝐵.
𝐵 ∩ 𝐴3
Then, by Axiom 3: 𝐵 ∩ 𝐴1 𝐵 ∩ 𝐴4
𝐵 ∩ 𝐴2
𝐴2
27
Law of Total Probability: Example
• In a particular urban area, 40% of work trips are suburb-to-city, 30% are suburb-to-
suburb, 20% are city-to-city, and 10% percent are city-to-suburb. The transit mode
shares for these trips are 30%, 2%, 50%, and 10%, respectively. What is the overall
share of work trips made by transit?
City Suburb
• Define the following events:
– 𝐴1 : suburb-to-city
– 𝐴2 : suburb-to-suburb
– 𝐴3 : city-to-city
40%
– 𝐴4 : city-to-suburb 20% 10% 30%
– 𝑇: transit
28
Learning Objective # 5
𝑛
Law of Total Probability: Example 𝑃 𝐵 = 𝑃 𝐵 𝐴𝑖 𝑃 𝐴𝑖
𝑖=1
• In a particular urban area, 40% of work trips are suburb-to-city, 30% are suburb-to-
suburb, 20% are city-to-city, and 10% percent are city-to-suburb. The transit mode
shares for these trips are 30%, 2%, 50%, and 10%, respectively. What is the overall
share of work trips made by transit? 𝑻
𝑺
𝐴1 𝐴3 𝐴4
• Define the following events:
– 𝐴1 : suburb-to-city 𝑃 𝐴1 = 0.4, 𝑃 𝑇 𝐴1 = 0.3
– 𝐴2 : suburb-to-suburb 𝑃 𝐴2 = 0.3, 𝑃 𝑇 𝐴2 = 0.02
– 𝐴3 : city-to-city 𝑃 𝐴3 = 0.2, 𝑃 𝑇 𝐴3 = 0.5
– 𝐴4 : city-to-suburb 𝑃 𝐴4 = 0.1, 𝑃 𝑇 𝐴4 = 0.1
– 𝑇: transit 𝐴2
29
Learning Objective # 5
Tree Diagrams
30
Tree Diagram
• Tree diagrams are useful tools to visualize all the possible outcomes for a
sequence of events and calculate their probabilities.
Draw 1 Draw 2 Outcomes
Multiply probabilities
along branches
Add probabilities
along columns
They should
31
add up to 1
Law of Total Probability Example: Tree Diagram
• In a particular urban area, 40% of work trips are suburb-to-city 𝐴1 , 30% are suburb-
to-suburb 𝐴2 , 20% are city-to-city 𝐴3 , and 10% percent are city-to-suburb 𝐴4 .
The transit mode shares for these trips are 30%, 2%, 50%, and 10%, respectively.
What is the overall share of work trips made by transit?
32
Learning Objective # 7
Bayes’ Theorem
33
Bayes’ Theorem
• If 𝐴1 , 𝐴2 , … , 𝐴𝑛 are a partition, then for any event 𝐵 with 𝑃 𝐵 > 0:
𝑃 𝐴𝑗 ∩ 𝐵 𝑃 𝐵 𝐴𝑗 𝑃 𝐴𝑗
𝑃 𝐴𝑗 𝐵 = = 𝑛
𝑃 𝐵 σ𝑖=1 𝑃 𝐵 𝐴𝑖 𝑃 𝐴𝑖
• Bayes’ theorem allows us to calculate one of the conditional probabilities
if we know its “converses”. Meaning, we flip the condition around and
calculate 𝑃 𝐴𝑗 𝐵 if we know 𝑃 𝐵 𝐴𝑖 for all 𝑖.
34
Bayes’ Theorem: Example
• An abandoned landfill potentially has groundwater contamination. Based on available
information, there’s a 70% chance that the groundwater is contaminated (C). To check for
contamination, we run some tests. However, the tests aren’t perfect. If the groundwater
is contaminated, there is a 90% chance that we will detect it (D). If the groundwater is not
contaminated, there’s a 5% chance we'll mistakenly detect contamination.
• If we detect contamination, what is the probability that there is contamination?
35
Learning Objective # 6
Bayes’ Theorem: Example
• If we detect contamination, what is the probability that there is contamination?
𝑃 𝐶 = 0.7 𝑃 𝐶 = 0.3 𝑃 𝐷 𝐶 = 0.9 𝑃 𝐷 𝐶 = 0.05
36
Learning Objective # 6
Summary
𝑃 𝐴∩𝐵
• The conditional probability of A given B has occurred is: 𝑃 𝐴 𝐵 =
𝑃 𝐵
• Multiplication rule (rearrange the conditional probability equation):
𝑃 𝐴∩𝐵 =𝑃 𝐴 𝐵 ∙𝑃 𝐵 and 𝑃 𝐵∩𝐴 =𝑃 𝐵 𝐴 ∙𝑃 𝐴
• 𝐴 and 𝐵 are independent if:
– 𝑃 𝐴 𝐵 = 𝑃(𝐴) or 𝑃(𝐵|𝐴) = 𝑃(𝐵)
– 𝑃 𝐴 ∩ 𝐵 = 𝑃(𝐴) ∙ 𝑃 𝐵
• Law of total probability: if 𝐴1 , 𝐴2 , … , 𝐴𝑛 are a partition, then:
𝑛
𝑃 𝐵 = 𝑃 𝐵 𝐴𝑖 𝑃 𝐴𝑖
𝑖=1
• Bayes' Theorem:
𝑃 𝐴𝑗 𝐵 𝑃 𝐵 𝐴𝑗 𝑃 𝐴𝑗
𝑃 𝐴𝑗 𝐵 = = 𝑛
𝑃 𝐵 σ𝑖=1 𝑃 𝐵 𝐴𝑖 𝑃 𝐴𝑖 37
Example
38
Example
• Consider a bridge that is susceptible to failure during an earthquake. Our analysis shows
that the chance that the intensity of the next earthquake is low (L) is 80%, that it is
medium (M) is 15%, and that it is high (H) is 5%. The chance of bridge failure (F) is 5%
during a L earthquake, 20% during a M earthquake, and 90% during a H earthquake.
• Draw a Venn diagram and a tree diagram
– Size of regions (area) ∝ probability
𝑆
39
Example
• Consider a bridge that is susceptible to failure during an earthquake. Our analysis shows
that the chance that the intensity of the next earthquake is low (L) is 80%, that it is
medium (M) is 15%, and that it is high (H) is 5%. The chance of bridge failure (F) is 5%
during a L earthquake, 20% during a M earthquake, and 90% during a H earthquake.
1. What is the probability that the next earthquake is low-intensity and causes failure?
L: 0.8 M H
0.15 0.05
40
Example
• Consider a bridge that is susceptible to failure during an earthquake. Our analysis shows
that the chance that the intensity of the next earthquake is low (L) is 80%, that it is
medium (M) is 15%, and that it is high (H) is 5%. The chance of bridge failure (F) is 5%
during a L earthquake, 20% during a M earthquake, and 90% during a H earthquake.
2. What is the probability that the next earthquake causes failure?
L: 0.8 M H
0.15 0.05
41
Example
• Consider a bridge that is susceptible to failure during an earthquake. Our analysis shows
that the chance that the intensity of the next earthquake is low (L) is 80%, that it is
medium (M) is 15%, and that it is high (H) is 5%. The chance of bridge failure (F) is 5%
during a L earthquake, 20% during a M earthquake, and 90% during a H earthquake.
3. If the bridge failed, what is the probability it was due to a high-intensity earthquake?
L: 0.8 M H
0.15 0.05
42
Example
• Consider a bridge that is susceptible to failure during an earthquake. Our analysis shows
that the chance that the intensity of the next earthquake is low (L) is 80%, that it is
medium (M) is 15%, and that it is high (H) is 5%. The chance of bridge failure (F) is 5%
during a L earthquake, 20% during a M earthquake, and 90% during a H earthquake.
4. Are the events bridge failure and high-intensity earthquake statistically independent?
L: 0.8 M H
0.15 0.05
43
Monty Hall Problem
• The Monty Hall problem is a probability puzzle based on the television game
show Let's Make a Deal and named after its original host, Monty Hall.
• Suppose you're on a game show, and you're given the choice of three doors.
Behind one door is a car; behind the others, goats. You pick a door, say D1,
and the host, who knows what's behind the doors, opens another door, say
D3, which has a goat. The host asks, "Do you want to switch to door D2?"
Is it to your advantage to switch your choice?
44
D1 D2 D3
Monty Hall Problem
• Assume you picked D1. Define the events:
– C1: The car is behind D1 (initial choice)
– C2: The car is behind D2.
– C3: The car is behind D3.
– H3: The host opens D3.
• Initially, the probabilities of C1, C2, C3 are:
• What is the probability of H3 given the possible locations of the car?
– 𝑃 𝐻3 𝐶1 =
– 𝑃 𝐻3 𝐶2 =
– 𝑃 𝐻3 𝐶3 =
45
D1 D2 D3
Monty Hall Problem
• Probability of winning if you switch given H3:
46