02.08 Lesson 8 of 12
1 hProbability & Conditional Probability
Represent uncertainty with events and probabilities, then update a probability when information about an event is known.
By the end of this lesson
You will be able to
- Define an event and a sample space.
- Calculate a conditional probability from observed counts.
- Distinguish independence from mutually exclusive events.
- Explain Bayes’ rule as probability updated by evidence.
Probability is a measure of uncertainty
An event is a set of outcomes from a sample space. For equally likely outcomes, P(A) = favourable outcomes / total outcomes. With observed data, a simple empirical estimate is count(A) / n. Probability values range from 0 to 1. Events are independent when learning that one occurred does not change the probability of the other.
rides = [0, 1, 1, 0, 1, 1, 0, 1]
observed_rate = sum(rides) / len(rides)
print(observed_rate) # 0.625 Condition on the information you have
Conditional probability is P(A | B) = P(A and B) / P(B), provided P(B) > 0. The denominator is the condition: the population or cases where B is known to be true. Bayes’ rule reverses the condition: P(A | B) = P(B | A)P(A) / P(B). It combines a prior probability with how likely the evidence is under that event.
# A small table of observed counts
# rain: 30 rainy hours, 70 dry hours
# high_demand among rainy: 18
# P(high_demand | rain) = 18 / 30
print(18 / 30) # 0.6 Apply what you learned
ExerciseCalculate conditional rates from a table
Use a made-up two-way table to make sure the condition is always reflected in the denominator.
- Create a table with 40 rainy hours and 60 dry hours.
- Record 24 high-demand rainy hours and 18 high-demand dry hours.
- Calculate
P(high demand | rain). - Calculate
P(rain | high demand)and explain why it is different. - State whether the counts alone prove that rain causes high demand.
You calculate P(high demand | rain) = 24/40 = 0.6 and P(rain | high demand) = 24/42; your explanation says association alone does not establish causation.
Free references
Study resources
- 01 Conditional Probability, Clearly Explained Video
Watch this one video and identify the event used as the condition in each example.
- 02 Conditional probability using two-way tables Article
Read the worked two-way-table example and calculate the conditional probability in both directions.
- 03 Bayes’ Theorem, Clearly Explained Video
Watch the standalone derivation after conditional probability; focus on prior, likelihood and posterior.
Check your understanding
Self-test
-
Question 1
In
P(A | B), what does the denominator represent?The probability of the condition event B; only outcomes where B occurred are in the conditioned population. -
Question 2
If A and B are independent, what is
P(A | B)?It equalsP(A), assumingP(B)is nonzero, because B provides no information about A.
Completion check
Move on when
You can calculate a conditional probability in the correct direction and explain why conditioning changes the denominator.