1. Home
  2. Explore
  3. Mathematics
  4. Bayes' Theorem Formulas

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Bayes' Theorem Formulas

🧠 Bayes' Theorem: Understanding Conditional Probability

Bayes' Theorem is a fundamental concept in probability theory that allows us to update the probability of an event based on new evidence. It's particularly useful for calculating the conditional probability of an event when we know the reverse conditional probability and other related probabilities.

📝 Conditional Probability Formulas

Before diving into Bayes' Theorem, it's crucial to understand the basic formulas for conditional probability:

  • Probability of A given B: The probability of event A occurring, given that event B has already occurred.

    P(A∣B)=P(A∩B)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}P(A∣B)=P(B)P(A∩B)​
  • Probability of B given A: The probability of event B occurring, given that event A has already occurred.

    P(B∣A)=P(B∩A)P(A)P(B|A) = \frac{P(B \cap A)}{P(A)}P(B∣A)=P(A)P(B∩A)​

💡 Deriving Bayes' Theorem

Bayes' Theorem can be derived by equating the expressions for P(A∩B)P(A \cap B)P(A∩B) and P(B∩A)P(B \cap A)P(B∩A).

  1. From the conditional probability formulas, we can express the probability of intersection:

    • P(A∩B)=P(A∣B)×P(B)P(A \cap B) = P(A|B) \times P(B)P(A∩B)=P(A∣B)×P(B)

    • P(B∩A)=P(B∣A)×P(A)P(B \cap A) = P(B|A) \times P(A)P(B∩A)=P(B∣A)×P(A)

  2. Since P(A∩B)=P(B∩A)P(A \cap B) = P(B \cap A)P(A∩B)=P(B∩A), we can set these two expressions equal:

    P(A∣B)×P(B)=P(B∣A)×P(A)P(A|B) \times P(B) = P(B|A) \times P(A)P(A∣B)×P(B)=P(B∣A)×P(A)
  3. To isolate P(A∣B)P(A|B)P(A∣B), which is the core of Bayes' Theorem, we divide both sides by P(B)P(B)P(B):

    P(A∣B)=P(B∣A)×P(A)P(B)P(A|B) = \frac{P(B|A) \times P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)×P(A)​

This is the basic formula of Bayes' Theorem. It allows us to calculate P(A∣B)P(A|B)P(A∣B) if we know P(B∣A)P(B|A)P(B∣A), P(A)P(A)P(A), and P(B)P(B)P(B).


🎯 Example 1: Numbers in a Bottle

Let's illustrate Bayes' Theorem with a simple example involving numbers.

🔢 Scenario Setup

Imagine a bottle containing pieces of paper with numbers.

  • Event A: Drawing numbers {1, 2, 3, 4, 5}

  • Event B: Drawing numbers {4, 5, 6, 7, 8, 9}

Our goal is to calculate P(A∣B)P(A|B)P(A∣B) using Bayes' Theorem.

📊 Venn Diagram Visualization

A Venn diagram helps visualize the events and their intersection:

  • Intersection (A∩BA \cap BA∩B): {4, 5} (common numbers)

  • Only A: {1, 2, 3}

  • Only B: {6, 7, 8, 9}

The sample space (all possible numbers) is {1, 2, 3, 4, 5, 6, 7, 8, 9}, which contains 9 unique numbers.

🧮 Calculating Individual Probabilities

To use Bayes' Theorem, we need P(A)P(A)P(A), P(B)P(B)P(B), and P(B∣A)P(B|A)P(B∣A).

  • P(A)P(A)P(A) (Probability of Event A):

    • Event A has 5 numbers ({1, 2, 3, 4, 5}) out of 9 total possible numbers.

    • P(A)=59P(A) = \frac{5}{9}P(A)=95​

  • P(B)P(B)P(B) (Probability of Event B):

    • Event B has 6 numbers ({4, 5, 6, 7, 8, 9}) out of 9 total possible numbers.

    • P(B)=69P(B) = \frac{6}{9}P(B)=96​

  • P(B∣A)P(B|A)P(B∣A) (Probability of B given A):

    • Conceptually, if A has already occurred, we are only considering the numbers in A ({1, 2, 3, 4, 5}).

    • Out of these 5 numbers, how many are also in B? Only {4, 5}, which are 2 numbers.

    • Therefore, P(B∣A)=25P(B|A) = \frac{2}{5}P(B∣A)=52​

✨ Applying Bayes' Theorem

Now, let's plug these values into the formula:

P(A∣B)=P(B∣A)×P(A)P(B)P(A|B) = \frac{P(B|A) \times P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)×P(A)​
P(A∣B)=25×5969P(A|B) = \frac{\frac{2}{5} \times \frac{5}{9}}{\frac{6}{9}}P(A∣B)=96​52​×95​​
P(A∣B)=2×55×969=104569P(A|B) = \frac{\frac{2 \times 5}{5 \times 9}}{\frac{6}{9}} = \frac{\frac{10}{45}}{\frac{6}{9}}P(A∣B)=96​5×92×5​​=96​4510​​

We can simplify by canceling the 5s in the numerator and then multiplying the top and bottom by 9:

P(A∣B)=2/96/9=26=13P(A|B) = \frac{2/9}{6/9} = \frac{2}{6} = \frac{1}{3}P(A∣B)=6/92/9​=62​=31​

So, the probability of A given B is 13\frac{1}{3}31​.

✅ Confirming with Conditional Probability

We can confirm this result using the direct conditional probability formula:

P(A∣B)=P(A∩B)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}P(A∣B)=P(B)P(A∩B)​
  • P(A∩B)P(A \cap B)P(A∩B): The intersection has 2 numbers ({4, 5}) out of 9 total. So, P(A∩B)=29P(A \cap B) = \frac{2}{9}P(A∩B)=92​.

  • P(B)P(B)P(B): We already found P(B)=69P(B) = \frac{6}{9}P(B)=96​.

  • P(A∣B)=2/96/9=26=13P(A|B) = \frac{2/9}{6/9} = \frac{2}{6} = \frac{1}{3}P(A∣B)=6/92/9​=62​=31​.

Both methods yield the same result, demonstrating the validity of Bayes' Theorem.


🩺 Example 2: Medical Screening for Prostate Cancer

Bayes' Theorem is particularly useful in real-world scenarios like medical diagnostics.

📝 Problem Statement

A study shows:

  • 12% of men develop prostate cancer.

  • A man with prostate cancer has a 95% chance of a positive test result.

  • A man without prostate cancer has a 6% chance of a false positive test result.

What is the probability that a man has cancer given that he has a positive test result?

🏷️ Defining Events and Probabilities

Let's define our events:

  • C: The man has cancer.

  • T+: The man has a positive test result.

  • C': The man does not have cancer.

Given probabilities:

  • P(C)=12%=0.12P(C) = 12\% = 0.12P(C)=12%=0.12

  • P(T+∣C)=95%=0.95P(T+|C) = 95\% = 0.95P(T+∣C)=95%=0.95 (Probability of positive test given cancer)

  • P(T+∣C′)=6%=0.06P(T+|C') = 6\% = 0.06P(T+∣C′)=6%=0.06 (Probability of positive test given no cancer - false positive)

We need to find P(C∣T+)P(C|T+)P(C∣T+).

📊 Applying Bayes' Theorem for Medical Screening

The Bayes' Theorem formula for this problem is:

P(C∣T+)=P(T+∣C)×P(C)P(T+)P(C|T+) = \frac{P(T+|C) \times P(C)}{P(T+)}P(C∣T+)=P(T+)P(T+∣C)×P(C)​

We have P(T+∣C)P(T+|C)P(T+∣C) and P(C)P(C)P(C), but we need to find P(T+)P(T+)P(T+) (the overall probability of a positive test result).

🌳 Using a Tree Diagram to Find P(T+)P(T+)P(T+)

A tree diagram helps visualize the different paths to a positive test result:

  1. Path 1: Has Cancer AND Positive Test

    • P(C)=0.12P(C) = 0.12P(C)=0.12

    • P(T+∣C)=0.95P(T+|C) = 0.95P(T+∣C)=0.95

    • P(C∩T+)=P(C)×P(T+∣C)=0.12×0.95=0.114P(C \cap T+) = P(C) \times P(T+|C) = 0.12 \times 0.95 = 0.114P(C∩T+)=P(C)×P(T+∣C)=0.12×0.95=0.114

  2. Path 2: Does NOT Have Cancer AND Positive Test (False Positive)

    • P(C′)=1−P(C)=1−0.12=0.88P(C') = 1 - P(C) = 1 - 0.12 = 0.88P(C′)=1−P(C)=1−0.12=0.88

    • P(T+∣C′)=0.06P(T+|C') = 0.06P(T+∣C′)=0.06

    • P(C′∩T+)=P(C′)×P(T+∣C′)=0.88×0.06=0.0528P(C' \cap T+) = P(C') \times P(T+|C') = 0.88 \times 0.06 = 0.0528P(C′∩T+)=P(C′)×P(T+∣C′)=0.88×0.06=0.0528

The overall probability of a positive test result, P(T+)P(T+)P(T+), is the sum of probabilities of these two paths:

P(T+)=P(C∩T+)+P(C′∩T+)=0.114+0.0528=0.1668P(T+) = P(C \cap T+) + P(C' \cap T+) = 0.114 + 0.0528 = 0.1668P(T+)=P(C∩T+)+P(C′∩T+)=0.114+0.0528=0.1668

🧪 Final Calculation with Bayes' Theorem

Now we have all the components for Bayes' Theorem:

  • P(T+∣C)=0.95P(T+|C) = 0.95P(T+∣C)=0.95

  • P(C)=0.12P(C) = 0.12P(C)=0.12

  • P(T+)=0.1668P(T+) = 0.1668P(T+)=0.1668

P(C∣T+)=0.95×0.120.1668P(C|T+) = \frac{0.95 \times 0.12}{0.1668}P(C∣T+)=0.16680.95×0.12​
P(C∣T+)=0.1140.1668≈0.68345P(C|T+) = \frac{0.114}{0.1668} \approx 0.68345P(C∣T+)=0.16680.114​≈0.68345

This means there is approximately a 68.3% chance that a man has cancer given that he has a positive test result.

⚠️ Interpreting the Result

It's important to note that even with a positive test result, there's still a significant chance (approximately 1−0.683=0.3171 - 0.683 = 0.3171−0.683=0.317 or 31.7%) that the man does not have cancer. This highlights the importance of understanding false positives in medical testing and why further diagnostic steps are often necessary.


🔢 Alternative Method: Using a Hypothetical Population

Another way to approach this problem is by considering a hypothetical population (e.g., 10,000 men). This method often makes the probabilities more intuitive.

Let's assume a population of 10,000 men.

  1. Men with Cancer:

    • 12%12\%12% of 10,000 = 0.12×10,000=1,200 men0.12 \times 10,000 = \textbf{1,200 men}0.12×10,000=1,200 men

  2. Men without Cancer:

    • 88%88\%88% of 10,000 = 0.88×10,000=8,800 men0.88 \times 10,000 = \textbf{8,800 men}0.88×10,000=8,800 men

Now, let's look at test results within these groups:

  1. Positive Test among Men with Cancer (T+∣CT+|CT+∣C):

    • 95%95\%95% of 1,200 = 0.95×1,200=1,140 men0.95 \times 1,200 = \textbf{1,140 men}0.95×1,200=1,140 men (True Positives)

    • Negative Test among Men with Cancer (T−∣CT-|CT−∣C): 5%5\%5% of 1,200 = 60 men

  2. Positive Test among Men without Cancer (T+∣C′T+|C'T+∣C′ - False Positives):

    • 6%6\%6% of 8,800 = 0.06×8,800=528 men0.06 \times 8,800 = \textbf{528 men}0.06×8,800=528 men (False Positives)

    • Negative Test among Men without Cancer (T−∣C′T-|C'T−∣C′): 94%94\%94% of 8,800 = 8,272 men

📈 Calculating P(C∣T+)P(C|T+)P(C∣T+) with Hypothetical Population

We want to find the probability that a man has cancer given a positive test result.

  • Total men with a positive test result:

    • True Positives (from cancer group) + False Positives (from no cancer group)

    • 1,140+528=1,668 men1,140 + 528 = \textbf{1,668 men}1,140+528=1,668 men

  • Men with cancer among those with a positive test result:

    • This is the number of True Positives: 1,140 men

Now, calculate the conditional probability:

P(C∣T+)=Number of men with Cancer AND Positive TestTotal number of men with Positive TestP(C|T+) = \frac{\text{Number of men with Cancer AND Positive Test}}{\text{Total number of men with Positive Test}}P(C∣T+)=Total number of men with Positive TestNumber of men with Cancer AND Positive Test​
P(C∣T+)=11401668≈0.68345P(C|T+) = \frac{1140}{1668} \approx 0.68345P(C∣T+)=16681140​≈0.68345

Both methods (Bayes' Theorem formula and hypothetical population) yield the same result, confirming that there is approximately a 68.3% chance that a man has cancer given a positive test result. This demonstrates the power and practicality of Bayes' Theorem in understanding conditional probabilities in real-world contexts.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent