Bayes’ Theorem and Examples | Data Science & AI

 

Bayes’ Theorem and Examples

Formula

The formula for Bayes’ Theorem is given by:

$$ P(E_i | A) = \frac{P(E_i) P(A | E_i)}{\sum_{j=1}^{n} P(E_j) P(A | E_j)} $$

Key Terminology

  • \(E_i\) are hypotheses or possible causes.
  • \(P(E_i)\) is the prior probability of \(E_i\).
  • \(P(E_i | A)\) is the posterior probability of \(E_i\).
  • The denominator ensures normalization over all possible hypotheses.

Example 1: Probability of a Red Ball from Bag II

Problem: Suppose we have two bags:

  • Bag I: 3 red, 4 black
  • Bag II: 5 red, 6 black
  • A bag is randomly chosen, and a red ball is drawn. Find the probability that it was from Bag II.

Step 1: Define Probabilities

$$ P(B_1) = \frac{1}{2}, \quad P(B_2) = \frac{1}{2} $$

$$ P(R | B_1) = \frac{3}{7}, \quad P(R | B_2) = \frac{5}{11} $$

Step 2: Apply Bayes’ Theorem

$$ P(B_2 | R) = \frac{P(B_2) P(R | B_2)}{P(B_1) P(R | B_1) + P(B_2) P(R | B_2)} $$

$$ = \frac{\frac{1}{2} \times \frac{5}{11}}{\frac{1}{2} \times \frac{3}{7} + \frac{1}{2} \times \frac{5}{11}} = \frac{5}{8} $$

Example 2: Probability of Another Gold Coin

Problem: Three boxes contain:

  • Box I: 2 gold coins
  • Box II: 2 silver coins
  • Box III: 1 gold, 1 silver
  • A box is randomly selected, and a gold coin is drawn. Find the probability that the other coin is also gold.

Step 1: Assign Probabilities

$$ P(B_1) = P(B_2) = P(B_3) = \frac{1}{3} $$

$$ P(G | B_1) = 1, \quad P(G | B_2) = 0, \quad P(G | B_3) = \frac{1}{2} $$

Step 2: Apply Bayes’ Theorem

$$ P(B_1 | G) = \frac{P(B_1) P(G | B_1)}{P(B_1) P(G | B_1) + P(B_3) P(G | B_3)} $$

$$ = \frac{\frac{1}{3} \times 1}{\frac{1}{3} \times 1 + \frac{1}{3} \times \frac{1}{2}} = \frac{2}{3} $$

PDF

Bayes Theorem and Examples

Video

Connect with PostNetwork Academy

Thank You!

 

©Postnetwork-All rights reserved.