MATHEMATICS FOR AI • LESSON 4

Conditional Probability

Conditional probability tells us how likely something is to happen when we already know that another event has happened. This is extremely useful in AI because new information can change the probability of an outcome.

CORE IDEA

Conditional probability means probability with additional information.

Instead of asking only "How likely is A?", we ask "How likely is A, given that we already know B?"

01

What Is Conditional Probability?

In basic probability, we might ask:

What is the probability of rain?

Conditional probability gives us additional information. For example:

What is the probability of rain
given that the sky is cloudy?

The information that the sky is cloudy can change our estimate of the probability of rain.

That is the basic idea behind conditional probability.

02

Why Do We Need Conditional Probability?

In the real world, we rarely make decisions without any information.

We usually have some evidence that helps us make a better prediction.

Without information:

Probability of rain = 30%

        ↓

We see dark clouds

        ↓

New information

        ↓

Probability of rain = 75%

The probability changed because we received new information.

AI systems do the same thing. They use available information to update the probability of different outcomes.

03

Understanding the Notation

Conditional probability is commonly written as:

::contentReference[oaicite:0]{index=0}

We read this as:

Probability of A
given B

The vertical line | means "given that".

So:

P(A | B)

means:

Probability of A
given B
04

A Simple Dice Example

Let's use a dice because it makes the idea very easy to see.

A normal dice has:

1, 2, 3, 4, 5, 6

Suppose we roll the dice and ask:

What is the probability of rolling 6?

P(6) = 1 / 6

Now imagine we receive new information:

We know the number rolled is greater than 3.

The possible numbers are now only:

4, 5, 6

There are now 3 possible outcomes instead of 6.

Only one of those outcomes is 6:

Favorable outcomes = 1

Possible outcomes = 3

Probability = 1 / 3

Probability ≈ 33.3%

The probability changed because we received additional information.

05

Think of It as Filtering Information

One of the easiest ways to understand conditional probability is to think of it as filtering.

All possible outcomes

1  2  3  4  5  6
        ↓
Filter:
"Number is greater than 3"
        ↓
4  5  6
        ↓
Ask:
"What is the probability of 6?"
        ↓
1 / 3

The condition removes the outcomes that no longer matter.

This is a very useful mental model for understanding conditional probability.

06

Conditional Probability in AI

Now let's connect this idea to AI.

Imagine an online store wants to predict whether a customer will purchase a product.

Without additional information, the system might estimate:

Probability of purchase = 10%

Now the system learns that the customer has already added the product to their cart.

Customer added product to cart
        ↓
New information
        ↓
Probability of purchase = 70%

The probability increased because the AI received useful information about the customer.

07

Spam Detection Example

Conditional probability is also useful for spam detection.

Suppose an email contains the word:

"Congratulations"

The AI can ask:

What is the probability that this email is spam
given that it contains "Congratulations"?

In probability notation, this could be represented as:

P(Spam | "Congratulations")

The model can use this information together with other features to make a better prediction.

08

Medical Example

Imagine an AI system helping doctors analyze a patient's information.

Initially:

Probability of disease = 5%

Then the system receives new information:

Patient has a specific symptom.

The probability might change:

Probability of disease
given the symptom = 30%

The important point is not the exact numbers. The important point is that new evidence changes the probability.

09

Conditional Probability Formula

The mathematical formula is:

P(A | B) = P(A and B)
           ------------
              P(B)

The idea behind the formula is simple:

Probability of A given B

        =

Probability that A and B happen together

        ÷

Probability of B

You don't need to memorize the formula immediately. First understand the meaning of "given".

10

Step-by-Step Example

Suppose we have 100 customers.

100 customers

40 customers visited the product page.

20 customers visited the product page
and purchased the product.

We want to know:

What is the probability of purchase
given that the customer visited
the product page?

Once we know the customer visited the product page, we only consider those 40 customers.

Customers who visited page = 40

Customers who visited page
and purchased = 20

Probability = 20 / 40

Probability = 0.5

Percentage = 50%

Therefore:

P(Purchase | Visited Page) = 50%

This is conditional probability in a very practical situation.

11

Why This Is Important for Machine Learning

Machine learning models often receive multiple pieces of information about an input.

Customer data
    ↓
Age
    ↓
Previous purchases
    ↓
Pages visited
    ↓
Products viewed
    ↓
Time spent on website
    ↓
Prediction

The model can use these pieces of information to estimate probabilities for different outcomes.

Conceptually:

Probability of purchase
given customer information

P(Purchase | Customer Data)

This idea appears throughout machine learning and probabilistic AI.

12

Probability vs Conditional Probability

The difference is simple.

Probability

"What is the chance of rain?"

P(Rain)


Conditional Probability

"What is the chance of rain
given that the sky is cloudy?"

P(Rain | Cloudy)

The second question contains additional information.

That additional information can change the probability.

13

The Most Important Idea

Don't think of conditional probability as just another formula.

Think about it as:

Start with uncertainty
        ↓
Receive new information
        ↓
Filter the possibilities
        ↓
Recalculate probability
        ↓
Make a better prediction

This is exactly the kind of reasoning AI systems need when working with incomplete or uncertain information.

14

Connection to the Next Lessons

Conditional probability is an important building block for the rest of the Probability section.

Probability Basics
        ↓
How likely is something?

Conditional Probability
        ↓
How likely is something
given new information?

Probability Distributions
        ↓
How are many possible outcomes
represented?

Bayes' Theorem
        ↓
How do we update our belief
using new evidence?

Once you understand conditional probability, Bayes' Theorem becomes much easier to understand because Bayes' Theorem is built around conditional probabilities.

WHAT TO REMEMBER

Conditional probability means calculating probability using information we already know.

The symbol P(A | B) means "the probability of A given B". The key idea is simple: when new information becomes available, the probability of an outcome can change. AI uses this idea to make better predictions from available evidence.