Menu

Conditional Probability – Understanding Conditional Probability with Examples

Written by Jagdeesh | 3 min read

Probability is a field of study that deals with the likelihood of events occurring. One of the fundamental concepts in this field is “conditional probability.” At its core, conditional probability helps us understand the probability of an event occurring given that another event has already occurred. This concept is pivotal in many real-world scenarios, from medical diagnoses to financial forecasting.

In this Blog post we will learn:
1. Definition of Conditional Probability
2. Example 1: Drawing Cards
3. Example 2: Health Diagnosis
4. Example 3: Weather and Traffic
5. Conclusion

1. Definition of Conditional Probability

Mathematically, the conditional probability of Event $A$ given that Event $B$ has occurred is represented as:

$ P(A|B) = \frac{P(A \cap B)}{P(B)} $

Where:
– $ P(A|B) $ is the conditional probability of $A$ given $B$.
– $ P(A \cap B) $ is the probability of both $A$ and $B$ occurring.
– $ P(B) $ is the probability of $B$ occurring.

2. Example 1: Drawing Cards

Consider a deck of 52 playing cards. If you draw a card, the probability that it’s a King (Event $A$) is 4/52 or 1/13.

Now, suppose you know the card you’ve drawn is a face card (Event $B$). Given this information, the probability it’s a King has changed. There are 12 face cards (Kings, Queens, Jacks) in total. Of those, 4 are Kings. Therefore, the conditional probability of drawing a King given that you’ve drawn a face card is:

$ P(A|B) = \frac{4}{12} = \frac{1}{3} $

3. Example 2: Health Diagnosis

Suppose in a city, 1% of people have a particular disease (Event $A$). There’s a test for the disease, but it’s not perfect. If you have the disease, the test will correctly identify it 99% of the time. However, if you don’t have the disease, the test will still say you do 2% of the time.

If someone tests positive (Event $B$), what’s the probability they actually have the disease?

Using Bayes’ theorem:

$ P(A|B) = \frac{P(B|A) \times P(A)}{P(B)} $

Where:
– $ P(B|A) $ is the probability of testing positive given you have the disease, which is 0.99.
– $ P(A) $ is the probability of having the disease, which is 0.01.
– $ P(B) $ is the total probability of testing positive, which includes both true positives and false positives.

$ P(B) = P(A) \times P(B|A) + P(not A) \times P(B|not A) = 0.01 \times 0.99 + 0.99 \times 0.02 = 0.0297 $

Substituting these values in:

$ P(A|B) = \frac{0.99 \times 0.01}{0.0297} \approx 0.332 $

Thus, even if someone tests positive, there’s only a 33.2% chance they actually have the disease.

4. Example 3: Weather and Traffic

Suppose in a city, on any given day, there’s a 20% chance of rain (Event $A$). If it rains, there’s an 80% chance of traffic jams (Event $B$). On days without rain, there’s a 30% chance of traffic jams due to other factors.

If there’s a traffic jam, what’s the probability it rained?

$ P(A|B) = \frac{P(B|A) \times P(A)}{P(B)} $

Where:
– $ P(B|A) $ is the probability of a traffic jam given it rained, which is 0.80.
– $ P(A) $ is the probability of rain, which is 0.20.
– $ P(B) $ is the total probability of a traffic jam.

$ P(B) = P(A) \times P(B|A) + P(not A) \times P(B|not A) = 0.20 \times 0.80 + 0.80 \times 0.30 = 0.44 $

Substituting these values in:

$ P(A|B) = \frac{0.80 \times 0.20}{0.44} \approx 0.363 $

Therefore, given there’s a traffic jam, there’s a 36.3% chance it rained.

5. Conclusion

Conditional probability allows us to refine our predictions based on new information. It’s essential in various fields and helps professionals make informed decisions. Always remember to account for all possible scenarios when calculating conditional probabilities to ensure accurate predictions.

Free Course
Master Core Python — Your First Step into AI/ML

Build a strong Python foundation with hands-on exercises designed for aspiring Data Scientists and AI/ML Engineers.

Start Free Course
Trusted by 50,000+ learners
Jagdeesh
Written by
Related Course
Master Probability — Hands-On
Join 5,000+ students at edu.machinelearningplus.com
Explore Course
Get the full course,
completely free.
Join 57,000+ students learning Python, SQL & ML. One year of access, all resources included.
📚 10 Courses
🐍 Python & ML
🗄️ SQL
📦 Downloads
📅 1 Year Access
No thanks
🎓
Free AI/ML Starter Kit
Python · SQL · ML · 10 Courses · 57,000+ students
🎉   You're in! Check your inbox (or Promotions/Spam) for the access link.
⚡ Before you go

Python.
SQL. NumPy.
All free.

Get the exact 10-course programming foundation that Data Science professionals use.

🐍
Core Python — from first line to expert level
📈
NumPy & Pandas — the #1 libraries every DS job needs
🗃️
SQL Levels I–III — basics to Window Functions
📄
Real industry data — Jupyter notebooks included
R A M S K
57,000+ students
★★★★★ Rated 4.9/5
⚡ Before you go
Python. SQL.
All Free.
R A M S K
57,000+ students  ★★★★★ 4.9/5
Get Free Access Now
10 courses. Real projects. Zero cost. No credit card.
New learners enrolling right now
🔒 100% free ☕ No spam, ever ✓ Instant access
🚀
You're in!
Check your inbox for your access link.
(Check Promotions or Spam if you don't see it)
Or start your first course right now:
Start Free Course →
Scroll to Top
Scroll to Top
Course Preview

Machine Learning A-Z™: Hands-On Python & R In Data Science

Free Sample Videos:

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science