Menu

Probability and Conditional Probability

Probability and Conditional Probability

What Is Probability?

Probability measures how likely an event is to occur. Its value ranges from 0 to 1.

  • 0 means the event is impossible under the defined assumptions.
  • 0.5 means the event has a probability of 50%.
  • 1 means the event is certain under the defined assumptions.

For equally likely outcomes, probability can be calculated using:

[
P(A) = \frac{\text{Favorable outcomes}}{\text{Total possible outcomes}}
]

For example, when rolling a fair six-sided die, the probability of getting a 4 is:

[
P(4) = \frac{1}{6}
]

This formula assumes that all six outcomes are equally likely.

Basic Probability Rules

Complement rule: The probability that an event does not occur is:

[
P(\neg A) = 1 - P(A)
]

Addition rule: For two events, the probability that at least one occurs is:

[
P(A \cup B) = P(A) + P(B) - P(A \cap B)
]

If the events cannot occur together, then (P(A \cap B)=0).

Multiplication rule: For independent events:

[
P(A \cap B) = P(A)P(B)
]

Independence means that the occurrence of one event does not change the probability of the other.

What Is Conditional Probability?

Conditional probability measures the probability of an event given that another event has occurred.

It is represented as:

[
P(A \mid B) = \frac{P(A \cap B)}{P(B)}
]

Here, (P(A \mid B)) means the probability of event A given event B, assuming (P(B) > 0).

Consider a simple example involving a dataset of 100 emails:

  • 40 emails are spam.
  • 30 emails contain the word "offer."
  • 24 emails are both spam and contain the word "offer."

The probability that an email is spam given that it contains "offer" is:

[
P(\text{Spam} \mid \text{Offer}) = \frac{24}{30} = 0.8
]

Therefore, 80% of emails containing the word "offer" are spam in this example dataset.

This does not mean that every email containing the word is spam. It only describes the observed relationship in this particular dataset.

Python Example

spam_and_offer = 24
emails_with_offer = 30
probability = spam_and_offer / emails_with_offer
print("Probability:", probability)
print("Percentage:", probability * 100)

Output:

Probability: 0.8

Percentage: 80.0

Probability in AI Applications

Probability helps AI systems estimate uncertainty and make decisions when information is incomplete.

Common applications include:

  • Spam email classification.
  • Fraud detection.
  • Weather forecasting.
  • Speech recognition.
  • Risk estimation and recommendation systems.

A predicted probability should not automatically be treated as a guarantee. Its usefulness depends on the model, the data, and how well the probabilities are calibrated.

Practice Exercise

A box contains 3 red balls and 7 blue balls. One ball is selected at random.

  1. What is the probability of selecting a red ball?
  2. What is the probability of selecting a blue ball?
  3. If the selected ball is returned to the box before another selection, what is the probability of selecting two red balls in two independent draws?

Artificial Intelligence Tutorial

VA

Vishalini A



Learn via Video Course

Artificial Intelligence and Machine Learning Course Logo

Artificial Intelligence and Machine Learning Course

55 hrs



Get in Touch For Details