Bayes' Theorem: Build the Denominator Before You Divide
Learn Bayes' theorem through worked examples, probability tables, unequal bag selection, and a clear method for finding the total-probability denominator.
- 12th
- Study Advice
A shop receives notebooks from three suppliers. You pick a notebook, notice a printing defect, and want to know which supplier it probably came from.
It is tempting to choose the supplier with the highest defect rate. But what if that supplier provides only a tiny part of the shop’s stock? A much larger supplier might contribute more defective notebooks even with a lower defect rate.
That is the problem Bayes’ theorem helps us solve. We know something about the outcome and use it to reconsider the possible sources.
The most useful habit is surprisingly simple: find the probability of the observed outcome before dividing by it. Once the denominator makes sense, the formula becomes much easier to remember.
All numerical situations in this guide are original, hypothetical teaching examples.
Read the condition before reading the numbers
Suppose S means “the notebook came from supplier S” and D means “the notebook is defective”.
These two expressions answer different questions:
- P(D given S): among notebooks from S, what fraction are defective?
- P(S given D): among defective notebooks, what fraction came from S?
The words after “given” tell you which group you are looking inside. In the first question, your group is all notebooks from S. In the second, your group is all defective notebooks, including those from other suppliers.
In standard notation, “given” is written as a vertical bar. So P(S given D) is P(S | D). We will often write the word “given” to keep the direction easy to read.
Imagine highlighting a group on a classroom list. “Passed, given that the student attended revision” starts with the revision group. “Attended revision, given that the student passed” starts with the pass group. Changing the highlighted group can change the answer.
The formula, with each part explained
Let E1, E2, …, En be all the possible source events. Let A be the observed event.
The sources must form a partition: they do not overlap, they cover all possibilities, and each source used in the conditional calculations has positive probability. Also, P(A) must be positive so that conditioning on A is defined.
The total-probability formula is:
P(A) = P(E1) x P(A given E1) + … + P(En) x P(A given En)
Then Bayes’ theorem gives:
P(Ei given A) = [P(Ei) x P(A given Ei)] / P(A)
Here P(Ei) is the source’s probability before the observation, often called its prior probability. P(A given Ei) is the probability of the observation within that source, often called the likelihood. P(Ei given A) is the revised source probability, or posterior probability.
These conditions and formulas are set out in Penn State’s lesson on Bayes’ theorem.
You do not need to begin by memorising the terminology. Begin by understanding the three actions: multiply for each route, add the routes, and divide the requested route by the total.
Why the denominator includes every route
Return to the notebook shop. A defective notebook could have come from supplier A, supplier B, or supplier C. These are separate routes to the same observed outcome.
For a notebook to be both from A and defective, two things must happen: it must come from A, and it must be defective within A’s supply. Therefore, the route probability is:
P(A and D) = P(A) x P(D given A)
We do the same for B and C. Since each notebook has exactly one supplier, the three routes cannot overlap. Adding them gives the probability that a randomly selected notebook is defective.
This also explains why the denominator is not just the sum of the defect rates. Each defect rate describes a different group. The supply shares tell us how large those groups are in the whole stock.
Think of three streams flowing into one pool. Looking only at the concentration of pearls in each stream misses how much water that stream contributes. To find where a pearl in the pool probably came from, you need both the concentration and the stream’s contribution.
Worked example 1: three suppliers and one defective notebook
A shop receives 50% of its notebooks from A, 30% from B, and 20% from C. Their defect rates are 2%, 4%, and 5%, respectively.
A notebook is selected uniformly at random from the combined stock and is found to be defective. Find the probability that it came from B.
Step 1: define the events and the target
Let A, B, and C denote the supplier events, and let D denote a defective notebook.
We want P(B given D).
The notebook is already known to be defective. We are choosing between possible suppliers within the defective group.
Step 2: calculate every defective route
| Supplier | Supply share | Defect rate within supplier | Joint probability of supplier and defect |
|---|---|---|---|
| A | 0.50 | 0.02 | 0.010 |
| B | 0.30 | 0.04 | 0.012 |
| C | 0.20 | 0.05 | 0.010 |
| Total | 1.00 | Not added directly | 0.032 |
For example, B’s route is 0.30 x 0.04 = 0.012.
Step 3: state the total probability
P(D) = 0.010 + 0.012 + 0.010 = 0.032.
Thus, 3.2% of the combined stock is defective under the given model.
Notice that the answer lies between the smallest and largest defect rates, 2% and 5%. That is a useful check on a weighted average.
Step 4: divide the requested route by the total
P(B given D) = 0.012 / 0.032 = 3/8 = 37.5%.
The probability that the defective notebook came from B is 37.5%.
B supplies 30% of all notebooks but contributes 37.5% of the defective group. The defect observation has raised B’s probability because its defect rate is above the overall rate of 3.2%.
C has the highest defect rate, yet B is the most likely source of a defective notebook in this example. B’s larger supply share matters.
Check the answer using a group of 10,000
A frequency picture makes the same calculation feel less abstract. Imagine a batch that exactly follows the given proportions:
| Supplier | Notebooks in the illustrative batch | Defective notebooks |
|---|---|---|
| A | 5,000 | 100 |
| B | 3,000 | 120 |
| C | 2,000 | 100 |
| Total | 10,000 | 320 |
Of the 320 defective notebooks, 120 came from B. Therefore, the required probability is 120/320 = 3/8.
This is an illustrative frequency model, not a claim that every actual batch must contain exactly these counts. Its purpose is to make the denominator visible.
We can also check all three revised source probabilities:
- A: 100/320 = 5/16.
- B: 120/320 = 6/16.
- C: 100/320 = 5/16.
They add to 1. Once we know the notebook is defective, it must still come from exactly one of the three suppliers.
Worked example 2: bags selected with unequal probabilities
Bag I contains 4 red balls and 6 blue balls. Bag II contains 7 red balls and 3 blue balls.
A fair six-sided die selects the bag. If the result is 1 or 2, Bag I is chosen; otherwise, Bag II is chosen. One ball is then drawn uniformly at random from the selected bag.
Given that the ball is red, find the probability that Bag I was selected.
Start with the selection rule
There are two bags, but they are not equally likely to be selected.
P(I) = 2/6 = 1/3.
P(II) = 4/6 = 2/3.
Within the bags:
P(R given I) = 4/10 = 2/5.
P(R given II) = 7/10.
Build the red denominator
P(R) = (1/3 x 2/5) + (2/3 x 7/10).
P(R) = 2/15 + 7/15 = 3/5.
Reverse the condition
P(I given R) = (2/15) / (3/5) = 2/9.
Bag I was selected with probability 1/3 before the colour was known. After seeing a red ball, its probability falls to 2/9. That makes sense because red is less common in Bag I than in Bag II.
If the question instead selected either bag with probability 1/2, the answer would be 4/11. The ball counts would be unchanged; the first-stage selection rule would be different.
Worked example 3: a scanner flag and a rare condition
Suppose 1% of parcels in a warehouse have a damaged label. A scanner flags 90% of parcels with damaged labels. It also incorrectly flags 5% of parcels whose labels are not damaged.
A parcel is flagged. Find the probability that its label is actually damaged.
Let D mean damaged, N mean not damaged, and F mean flagged.
The given probabilities are:
P(D) = 0.01 and P(N) = 0.99.
P(F given D) = 0.90 and P(F given N) = 0.05.
Now calculate both routes to a flag:
- Damaged and flagged: 0.01 x 0.90 = 0.009.
- Not damaged and flagged: 0.99 x 0.05 = 0.0495.
P(F) = 0.009 + 0.0495 = 0.0585.
P(D given F) = 0.009 / 0.0585 = 2/13, approximately 15.38%.
The answer is not 90%. That 90% refers to how often a damaged label triggers a flag, not how often a flag indicates a damaged label.
To see the difference, imagine 10,000 parcels following the stated proportions. There would be 100 damaged labels, of which 90 are flagged, and 9,900 undamaged labels, of which 495 are flagged. The flagged group contains 585 parcels. Only 90 belong to the damaged group.
The flag still provides useful information: the probability of damage rises from 1% to about 15.38%. But the large number of undamaged parcels produces many incorrect flags.
This is why a small starting probability, sometimes called a base rate, cannot be left out of the calculation.
Worked example 4: two draws without replacement
Bag A contains 3 red and 2 blue balls. Bag B contains 1 red and 4 blue balls. A bag is selected with equal probability, and two balls are drawn from it without replacement.
Given that both balls are red, find the probability that Bag A was selected.
Let RR mean that both draws are red.
Within Bag A:
P(RR given A) = 3/5 x 2/4 = 3/10.
Within Bag B:
P(RR given B) = 1/5 x 0/4 = 0.
Bag B has only one red ball, so it cannot produce two red balls without replacement.
The total probability is:
P(RR) = (1/2 x 3/10) + (1/2 x 0) = 3/20.
Therefore:
P(A given RR) = (3/20) / (3/20) = 1.
The source events have positive probabilities, but a source’s likelihood for a particular observation can be zero. Here the evidence rules out Bag B completely.
What changes with replacement?
If each ball is replaced before the next draw, the likelihoods become:
P(RR given A) = 3/5 x 3/5 = 9/25.
P(RR given B) = 1/5 x 1/5 = 1/25.
With the same equal bag-selection probabilities:
P(A given RR) = (9/50) / (9/50 + 1/50) = 9/10.
Replacement changes the evidence probabilities inside each source. It does not change the overall Bayes structure.
What if the observation is “not defective”?
Return to the supplier example. Now suppose the notebook is known to be non-defective, denoted by N. Find P(B given N).
Use the non-defect rate within each supplier:
- A: 1 - 0.02 = 0.98.
- B: 1 - 0.04 = 0.96.
- C: 1 - 0.05 = 0.95.
P(N) = (0.50 x 0.98) + (0.30 x 0.96) + (0.20 x 0.95).
P(N) = 0.490 + 0.288 + 0.190 = 0.968.
P(B given N) = 0.288 / 0.968 = 36/121, approximately 29.75%.
You could also find P(N) as 1 - P(D) = 1 - 0.032 = 0.968. However, the numerator must still refer to B and a non-defective notebook.
Do not write P(B given N) = 1 - P(B given D). Those two expressions use different conditions.
The valid complementary statement is:
P(not B given D) = 1 - P(B given D).
Both sides keep the condition D fixed.
A short proof you can reconstruct
You can rebuild Bayes’ theorem from conditional probability instead of trying to recall a long fraction under pressure.
Start with the definition:
P(Ei given A) = P(Ei and A) / P(A).
Use the multiplication rule in the numerator:
P(Ei and A) = P(Ei) x P(A given Ei).
Finally, split A into its non-overlapping source routes and add their probabilities:
P(A) = P(E1) x P(A given E1) + … + P(En) x P(A given En).
Substituting these two expressions gives the formula. The denominator appears because we have restricted attention to outcomes in A; it rescales their source contributions to add to 1.
The partition and conditional-probability foundations are also covered in the NCERT Probability chapter hosted by SATHEE.
Common mistakes and how to repair them
Adding likelihoods without source weights
In the notebook example, 0.02 + 0.04 + 0.05 is not P(D). The rates belong to different supplier groups. Multiply each by its supply share first.
A plain average of the rates is appropriate only when the source probabilities are equal. Even then, writing the weights makes the reasoning easier to check.
Putting just the requested route in the denominator
If you divide B’s defective route by itself, you get 1. That ignores the defective notebooks from A and C.
Write one row per source before choosing the numerator. This makes missing routes easier to spot.
Treating source events as independent
“From A” and “from B” are mutually exclusive in a one-notebook selection. They are not independent events with positive probabilities.
Multiplication along a route uses a conditional probability. It does not require the source and the outcome to be independent.
If these terms feel similar, revisit our guide to mutually exclusive, exhaustive, and complementary events.
Multiplying two observation rates without checking dependence
For two draws without replacement, the first draw changes the contents of the bag. Use the updated counts for the second draw.
More generally, observing two things does not automatically justify multiplying their separate likelihoods. Use the probability of the full observation within each source, taking any dependence into account.
Using overlapping groups as sources
“Students who study Accounts” and “students who study Economics” may overlap. You cannot simply add their contributions as if each student belonged to one source only.
You could instead use non-overlapping categories such as Accounts only, Economics only, both, and neither, provided the question supplies enough information.
Rounding before the final division
Keep exact fractions or the full given decimals while calculating the routes. Round only the final answer when an approximation is needed. Label an approximate percentage as approximate.
A reliable answer-writing routine
For a full solution, use this order:
- Define the source events and the observed event.
- Write the exact probability requested.
- List each source probability and its likelihood for the observation.
- Multiply along every route to the observation.
- Add those routes to obtain the denominator.
- Divide the requested route by that denominator.
- Interpret the answer in one sentence.
Before finishing, check that the source probabilities add to 1, the denominator is positive, and the final answer lies between 0 and 1.
If you calculate all posterior source probabilities, they should also add to 1. If the observation is equally likely within every source, the posterior source probabilities should equal the priors: the observation gives you no reason to favour one source over another.
Try these six practice questions
Try writing the denominator before checking each solution.
1. Two delivery teams
Team A handles 60% of deliveries and Team B handles 40%. Their late-delivery rates are 5% and 10%. A randomly selected delivery was late. What is the probability that B handled it?
Solution: P(late) = 0.60 x 0.05 + 0.40 x 0.10 = 0.07. B’s route is 0.04. The required probability is 4/7, approximately 57.14%.
2. Equal bag selection
One of two bags is selected with probability 1/2 each. Bag A contains 2 green and 3 yellow balls. Bag B contains 4 green and 1 yellow ball. A green ball is drawn. Find the probability that A was selected.
Solution: P(green) = 1/2 x 2/5 + 1/2 x 4/5 = 3/5. A’s green route is 1/5. The answer is 1/3.
3. Evidence with equal likelihoods
A supplies 70% of a stock and B supplies 30%. Both have a defect rate of 4%. A defective item is selected. Find the probability it came from A.
Solution: P(defect) = 0.70 x 0.04 + 0.30 x 0.04 = 0.04. The answer is 0.028/0.04 = 0.70. The observation leaves the source probability unchanged.
4. A missing route
Three sources have probabilities 0.20, 0.50, and 0.30. Their probabilities of producing event E are 0.10, 0.20, and 0.40. A student uses 0.02 + 0.10 as the denominator. Correct the denominator and find the probability of the third source given E.
Solution: The missing route is 0.30 x 0.40 = 0.12. P(E) = 0.02 + 0.10 + 0.12 = 0.24. The requested probability is 0.12/0.24 = 1/2.
5. A parcel that was not flagged
Using the scanner example, find the probability that an unflagged parcel has a damaged label.
Solution: The damaged-unflagged route is 0.01 x 0.10 = 0.001. The undamaged-unflagged route is 0.99 x 0.95 = 0.9405. Thus P(unflagged) = 0.9415, and the answer is 2/1883, approximately 0.1062%.
6. Find an unknown prior
Two machines, A and B, produce a combined output. Their defect rates are 2% and 6%. Among defective items, half came from A. What fraction of total output comes from A?
Solution: Let P(A) = p, so P(B) = 1 - p.
0.02p / [0.02p + 0.06(1 - p)] = 1/2.
Therefore, 0.04p = 0.02p + 0.06 - 0.06p.
So 0.08p = 0.06 and p = 3/4.
Check: A’s defective route is 0.75 x 0.02 = 0.015; B’s is 0.25 x 0.06 = 0.015. Equal route contributions give equal shares of the defective group, even though the production shares differ.
Frequently asked questions
What is Bayes’ theorem in simple words?
It updates the probability of a possible source after an outcome is observed. You compare that source’s contribution to the outcome with the contributions from all possible sources.
How do I recognise a Bayes’ theorem question?
Look for a known outcome followed by a question about its source: a defective item and its supplier, a red ball and its bag, or a flagged parcel and its true condition. Then check whether the given conditional probabilities run in the opposite direction to the one requested.
What goes in the denominator of Bayes’ theorem?
The probability of the event after “given”. If the question asks for the probability of Bag A given a red ball, the denominator is the total probability of drawing red through all possible bag-selection routes.
Are P(A given B) and P(B given A) ever equal?
They can be equal in particular situations, but they are not interchangeable. Each is the same intersection divided by a different conditioning probability. Read what each expression asks before calculating.
Are two bags always selected with probability one-half each?
No. They have equal probabilities only if the selection procedure makes them equally likely. A die rule, a stated ratio, or another selection mechanism may give unequal priors.
Can a posterior probability be 1?
Yes. If the observed event is possible through the requested source and impossible through all other sources in the model, its posterior probability is 1. The two-red-balls example without replacement illustrates this.
Can I use Bayes’ theorem if the observed event has probability zero?
Not through the elementary event formula used here, because it would require division by zero. Recheck the question and your calculations if the denominator becomes zero.
Is total probability the same as Bayes’ theorem?
They answer different questions. Total probability combines all source routes to find the probability of an outcome. Bayes’ theorem uses that outcome probability to find a source probability after the outcome is known.
Should I use fractions or decimals?
Either is fine if you remain consistent. Fractions are helpful for bag and die questions; decimals often suit percentages. Keep intermediate calculations exact where possible, and round only at the end.
What is the quickest way to check my answer?
Check that your numerator is one of the nonnegative contributions included in your denominator. The result must lie between 0 and 1. Then explain it as a fraction of the observed group; if your sentence describes a different group, revisit the condition.
Looking for commerce tuitions?
Prachi is a gold-medalist commerce teacher with experience at Deloitte and KPMG. She focuses on fundamentals to build a strong foundation.