Bayes' Theorem
Medication dosages, IV drip rates, vital monitoring
Bayesβ theorem lets you reverse a conditional probability. If you know β the probability of B given A β Bayesβ theorem tells you β the probability of A given B. This is essential in medicine, quality control, and any situation where you need to update your beliefs based on new evidence.
The Formula
The denominator is the total probability of B, which can be expanded using the law of total probability:
where denotes βnot Aβ (the complement of A).
Terminology:
- = prior probability β what you believed before seeing the evidence
- = posterior probability β your updated belief after seeing the evidence
- = likelihood β how likely the evidence is if A is true
- = total probability of the evidence β how likely the evidence is overall
Intuition: Why Bayesβ Theorem Matters
Imagine a medical test that is 99% accurate. You test positive. Are you 99% likely to have the disease?
Almost certainly not. The answer depends on how common the disease is. If the disease is rare (say, 1 in 1,000 people), then most positive test results will actually be false positives from the large number of healthy people being tested. Bayesβ theorem gives you the mathematical framework to calculate the actual probability.
This counterintuitive result is so important β and so commonly misunderstood β that it has its own name: the base rate fallacy. People naturally focus on the testβs accuracy and ignore the base rate (prevalence) of the condition.
Step-by-Step: The Medical Test Problem
Example 1: Disease Screening
A disease affects 1% of the population. A screening test has the following characteristics:
- Sensitivity: β the test correctly detects 95% of people who have the disease
- False positive rate: β the test incorrectly flags 10% of healthy people (equivalently, specificity is 90%)
A randomly selected person tests positive. What is the probability they actually have the disease?
Define the events:
- = has the disease,
- = does not have the disease,
- = tests positive
Apply Bayesβ theorem:
Step 1: Calculate the numerator.
Step 2: Calculate each term in the denominator.
Step 3: Add to get the total probability of a positive test.
Step 4: Divide.
Answer: Despite a positive test, there is only about an 8.8% chance the person actually has the disease.
Why so low? Out of every 1,000 people tested, about 10 have the disease and 990 do not. The test catches true positives, but it also produces false positives. So roughly 9.5 out of 108.5 total positive results are genuine β that is about 8.8%.
The Tree Diagram Approach
A tree diagram provides an alternative visual method for Bayesβ theorem problems. Draw the prior probabilities as the first set of branches, then the test results as the second set, and multiply along each path to get joint probabilities.
Tree Diagram: Disease Screening with Bayesβ Theorem
Reading the tree: Multiply along each complete path from root to leaf.
| Path | Calculation | Joint Probability |
|---|---|---|
| Disease and Positive | ||
| Disease and Negative | ||
| No Disease and Positive | ||
| No Disease and Negative |
Verification: All joint probabilities must sum to 1.
To find , take the βDisease and Positiveβ path and divide by the total probability of a positive result:
This confirms the formula-based result: about 8.8%.
How Prevalence Affects Results
The same test produces dramatically different results depending on how common the disease is. The table below uses the same test (sensitivity 95%, specificity 90%) with varying prevalence rates.
| Prevalence | ||||
|---|---|---|---|---|
| 0.1% | ||||
| 1% | ||||
| 5% | ||||
| 10% | ||||
| 50% |
Key insight: When a disease is very rare (0.1%), a positive result means less than a 1% chance of actually having the disease. When the disease is common (50%), the same positive result means a 90.5% chance. The test itself did not change β the prevalence (base rate) did.
This is why:
- Screening tests work best on high-risk populations (higher prevalence)
- A positive screening result in a general population is often followed by a more specific confirmatory test
- Doctors target screenings to groups where the condition is more common
Bayesβ Theorem with More Than Two Categories
Bayesβ theorem extends naturally when there are more than two possible causes. If events are mutually exclusive and exhaustive:
Example 2: Three Factories
Three factories supply a retailer. Factory X makes 50% of products with a 3% defect rate, Factory Y makes 30% with a 4% defect rate, and Factory Z makes 20% with a 6% defect rate. A product is found to be defective. What is the probability it came from Factory Z?
Step 1: Calculate the numerator for Factory Z.
Step 2: Calculate the total probability of a defect.
Step 3: Apply Bayesβ theorem.
Answer: About 30.8% of defective products come from Factory Z. Despite making only 20% of products, Factory Z produces a disproportionate share of defects due to its higher defect rate.
Real-World Application: Nursing β Interpreting a Positive Drug Screen
Workplace drug testing is a practical Bayesβ theorem scenario that nurses and occupational health professionals encounter regularly.
A company requires drug screening for all employees. Here are the numbers:
- Drug use prevalence among employees: 4% ()
- Test sensitivity: 97% β the test detects 97% of actual users ()
- Test specificity: 95% β the test correctly clears 95% of non-users (, so )
An employee tests positive. What is the probability they actually use drugs?
Answer: Only about 44.7% of positive results are true positives. More than half of positive test results in this scenario are false alarms.
This is why occupational health protocols require confirmatory testing (usually a more specific test like GC-MS) before any employment action is taken. A nurse or HR professional who understands Bayesβ theorem can explain to an anxious employee why a single positive screening result is not conclusive, and why the follow-up test matters.
Practice Problems
Test your understanding with these problems. Click to reveal each answer.
Problem 1: A rare disease affects 0.5% of the population. A test has 98% sensitivity and 96% specificity. If a person tests positive, what is the probability they have the disease?
, , ,
Answer: About 11.0% β even with a highly accurate test, the rarity of the disease means most positive results are false positives.
Problem 2: Using the disease from Example 1 (prevalence 1%, sensitivity 95%, specificity 90%), a person tests negative. What is the probability they actually have the disease? That is, find .
,
Answer: About 0.056% β a negative result makes it extremely unlikely the person has the disease. This is reassuring.
Problem 3: A factory gets 40% of its parts from Supplier A (2% defect rate) and 60% from Supplier B (5% defect rate). A defective part is found. What is the probability it came from Supplier B?
Answer: About 78.9% of defective parts come from Supplier B.
Problem 4: An email filter correctly identifies 99% of spam (sensitivity) and correctly passes 97% of legitimate email (specificity). If 20% of all incoming email is spam, what is the probability that a flagged email is actually spam?
, , ,
Answer: About 89.2% of flagged emails are actually spam. The relatively high prevalence of spam (20%) makes the filter more reliable than a rare-disease medical test.
Problem 5: A disease has 10% prevalence. The test has 90% sensitivity and 85% specificity. Find and explain whether this test is reliable enough for screening.
, , ,
Answer: , or 40%. Only 40% of positive results are true positives. Whether this is βreliable enoughβ depends on context: if the follow-up test is low-cost and low-risk, a 40% hit rate may be acceptable for initial screening. If the follow-up is invasive or expensive, a more specific test might be preferable.
Key Takeaways
- Bayesβ theorem reverses conditional probabilities: knowing , find .
- The formula is: .
- Base rate (prevalence) matters enormously. A positive result from a highly accurate test can still be mostly wrong if the condition is rare.
- The tree diagram approach provides a visual alternative: multiply along branches to get joint probabilities, then divide to get the posterior.
- In medical contexts, sensitivity tells you , but patients and clinicians need β Bayesβ theorem bridges this gap.
- Confirmatory testing exists because initial screening results have limited predictive value, especially in low-prevalence populations.
- Bayesβ theorem extends to multiple categories by expanding the denominator to sum over all possible causes.
Return to Statistics for more topics in this section.
Next Up in Statistics
All Statistics topicsLast updated: March 29, 2026