Skip to main content

Conditional Probability

In the real world, events are rarely isolated. The probability of it raining is higher given that it is cloudy. The probability of a user clicking an ad is higher given their past search history. This "given" is the essence of Conditional Probability.

1. The Definition

Conditional probability is the probability of an event AA occurring, given that another event BB has already occurred. It is denoted as P(AB)P(A|B).

The formula is:

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

Where:

  • P(AB)P(A \cap B) is the Joint Probability (both AA and BB happen).
  • P(B)P(B) is the probability of the condition (the "new universe").

2. Intuition: Shrinking the Universe

Think of probability as a "Universe" of possibilities. When we say "given BB," we are throwing away every part of the universe where BB did not happen. Our new total area is just BB.



3. Independent vs. Dependent Events

How do we know if one event affects another? We look at their conditional probabilities.

A. Independent Events

Event A and B are independent if the occurrence of B provides zero new information about AA.

  • Mathematical Check: P(AB)=P(A)P(A|B) = P(A)
  • Example: Rolling a 6 on a die given that you ate an apple for breakfast.

B. Dependent Events

Event A and B are dependent if knowing B happened changes the likelihood of AA.

  • Mathematical Check: P(AB)P(A)P(A|B) \neq P(A)
  • Example: Having a cough (A)(A) given that you have a cold (B)(B).

4. The Multiplication Rule

We can rearrange the conditional probability formula to find the probability of both events happening:

This is the foundation for the Chain Rule of Probability, which allows ML models to calculate the probability of a long sequence of events (like a sentence in an LLM).

5. Application: Predictive Modeling

In Machine Learning, almost every prediction is a conditional probability.

  • Medical Diagnosis: P(DiseaseSymptoms)P(\text{Disease} \mid \text{Symptoms})
  • Spam Filter: P(SpamWords in Email)P(\text{Spam} \mid \text{Words in Email})
  • Self-Driving Cars: P(Pedestrian crossesCamera Image)P(\text{Pedestrian crosses} \mid \text{Camera Image})

If we flip the question—if we know P(AB)P(A|B) but we want to find P(BA)P(B|A) we use the most powerful tool in probability theory.