Bayes Theorem
📘 Bayes’ Theorem & Total Probability
Introduction to Bayes’ Theorem
Bayes’ Theorem provides a way to compute the conditional probability of an event given that another event has occurred. In particular, it helps find the “inverse” probability: if we know P(A∣B), we can find P(B∣A). This is crucial in many real-world scenarios where we observe an effect and want to infer the most likely cause.
Formal Statement
Let B1,B2,…,Bn be a set of events that satisfy:
They are mutually exclusive (no two can occur together).
Their union is the entire sample space S (they form a partition of S).
P(Bi)=0 for each i.
Then for any event A (that can occur with one of the Bi), the total probability of A is:
And Bayes’ Theorem gives the posterior probability of a particular Bi given A:
Interpretation: P(Bi) is the prior probability (before observing A), and P(Bi∣A) is the posterior probability (after observing A). Bayes’ theorem updates our belief about Bi in light of new evidence A.
Example 1: Defective Bolts from Vendors
Setup: A company orders bolts from three vendors:
Vendor A: supplies 30% of bolts, with 2% defective.
Vendor B: supplies 40% of bolts, with 3% defective.
Vendor C: supplies 30% of bolts, with 5% defective.
All bolts are mixed together. A bolt is chosen at random and found to be defective.
Step 1: Define Events
A, B, C: the bolt came from vendor A, B, or C respectively.
D: the bolt is defective.
Given probabilities:
P(A)=0.30,P(B)=0.40,P(C)=0.30
P(D∣A)=0.02,P(D∣B)=0.03,P(D∣C)=0.05
Step 2: Total Probability of Defective
So the overall probability that a randomly chosen bolt is defective is 0.033 (or 3.3%).
Step 3: Bayes’ Theorem – Find Probability It Came from a Particular Vendor
Probability it came from Vendor A given it is defective:
Probability it came from Vendor B:
Probability it came from Vendor C:
Check: 112+114+115=1, as expected.
Key idea: Total probability gives P(D), then Bayes’ theorem uses P(D) as denominator to compute each posterior probability.
Example 2: Professors and New Subject Introduction
Setup: Three candidates X, Y, Z for a professor post. Their chances of selection are in proportion 4:2:3. If selected:
X will introduce a new subject with probability 0.35
Y with probability 0.52
Z with probability 0.80
Step 1: Prior Probabilities
Total proportion = 4+2+3=9.
Step 2: Event of Introducing New Subject
Let N = “new subject is introduced”. The conditional probabilities are:
Step 3: Total Probability of New Subject
Simplify (optional):
Thus the probability that a new subject will be introduced in the department is 0.5378 (or about 53.78%).
Note: This is a straightforward total probability problem. No Bayes inversion is needed here because the question only asks for P(N), not the probability that a specific candidate was selected given N.
Example 3: Three Boxes with Colored Balls
Setup: There are three boxes containing:
Box 1: 1 white, 2 red, 3 black balls (total 6)
Box 2: 2 white, 3 red, 1 black ball (total 6)
Box 3: 3 white, 1 red, 2 black balls (total 6)
A box is chosen at random, and then two balls are drawn from it without replacement. The two balls are one red and one white.
Question: Given that the two drawn balls are one red and one white, what is the probability they came from Box 1?
Step 1: Prior Probabilities
Since a box is chosen at random:
Step 2: Conditional Probabilities of Drawing One Red and One White from Each Box
Let E = “one red and one white ball are drawn”.
Box 1:
Total ways to choose 2 balls from 6: (26)=15
Ways to get 1 red (from 2) and 1 white (from 1): (12)(11)=2
So P(E∣Box 1)=152
Box 2:
Total ways: 15
Ways: 1 red from 3, 1 white from 2: (13)(12)=6
So P(E∣Box 2)=156=52
Box 3:
Total ways: 15
Ways: 1 red from 1, 1 white from 3: (11)(13)=3
So P(E∣Box 3)=153=51
Step 3: Total Probability of Event E
Step 4: Bayes’ Theorem – Probability It Came from Box 1
The required probability is 112.
Example 4: Bridge Collapse – Wrong Design or Inferior Material
Setup: A bridge may collapse due to wrong designing (WD) or inferior material (IM). Given:
Probability of wrong designing: P(WD)=10%=0.10
Hence P(IM)=1−0.10=0.90
If designing is wrong, probability of collapse: P(Collapse∣WD)=95%=0.95
If inferior material, probability of collapse: P(Collapse∣IM)=45%=0.45
Question: The bridge collapsed. Find the probability that it was due to wrong designing.
Step 1: Define Events and Given Probabilities
C = collapse
P(WD)=0.10, P(IM)=0.90
P(C∣WD)=0.95, P(C∣IM)=0.45
Step 2: Total Probability of Collapse
Step 3: Bayes’ Theorem – Probability of Wrong Designing Given Collapse
Thus the chance that the collapse was due to wrong designing is 0.19 (or 19%).
Key insight: Even though faulty designs are much more likely to cause collapse (95% vs 45%), the prior probability of bad design is only 10%. So after observing a collapse, the posterior probability that design was at fault is only 19%.
Example 5: Coins – True vs False (Two-Headed)
Setup: There are 3 true coins (one head, one tail) and 1 false coin (heads on both sides). A coin is chosen at random and tossed 4 times. Heads appear all 4 times.
Question: What is the probability that the chosen coin was the false coin?
Step 1: Prior Probabilities
Total coins = 4, so:
Step 2: Conditional Probabilities of Getting 4 Heads
Let H4 = “4 heads in 4 tosses”.
For a true coin: probability of head in one toss = 1/2. Tosses independent, so P(H4∣True)=(21)4=161.
For the false coin (heads on both sides): every toss yields heads for sure, so P(H4∣False)=1.
Step 3: Total Probability of Getting 4 Heads
Step 4: Bayes’ Theorem – Probability It Is the False Coin
The required probability is 1916 (approximately 0.8421).
Observation: Even though the false coin is only 1 out of 4 coins, seeing four heads makes it very likely (about 84%) that we picked the false coin.
Summary of Bayes’ Theorem Workflow
Identify the partition: a set of mutually exclusive and exhaustive events B1,B2,…,Bn (the “causes”).
List the prior probabilities P(Bi).
List the conditional probabilities P(A∣Bi) of the observed event A under each cause.
Compute total probability P(A)=∑P(Bi)P(A∣Bi).
Apply Bayes’ theorem to find any posterior probability: $$P(B_i|A) = \frac{P(B_i)P(A|B_i)}{P(A)}$$
This framework is used across science, engineering, machine learning, and decision making to update beliefs with evidence.

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