Lesson 26 of 42 · Counting, probability and statistics
Conditional probability, total probability and Bayes
Restrict the sample space to what you know, use trees for total probability, and turn Bayes questions into a frequency table you can trust.
About 25 minutes
In this lesson
- Compute a conditional probability from a table, a formula or a reduced sample space.
- Find an overall probability with the total probability theorem.
- Reverse a conditional probability with Bayes, and check it with a frequency table.
The idea
What "given" does
, read "the probability of given ", is the probability of once you know that has happened. Knowing throws away every outcome outside : the sample space shrinks to , and you ask what share of it also lies in .
With counts, the same idea is simply "how many in both, out of how many in ". The denominator is the condition, never the whole population.
Order matters
and are different numbers with the same numerator and different denominators. In a class of 30 where 10 students play chess and 4 of those also play the piano, while 8 students play the piano in all: , but . Before computing, say aloud which group you are restricted to.
The multiplication rule and trees
Rearranging the definition gives
This is what you use when an experiment happens in stages, such as drawing without replacement or choosing a supplier and then testing a part. A tree displays it: the first branches carry and ; the branches after them carry conditional probabilities; the probability of a path is the product along it. The branches leaving any point must add up to 1.
and are independent exactly when : knowing changes nothing.
Total probability
If the sample space is split into separate cases that cover everything (three factories, two machines, "has the condition" and "does not"), then
On a tree, this is "add every path that ends in ". It is the sum rule and the multiplication rule working together.
Bayes' theorem
Often the question gives and asks for : the defect rate of a machine is known, and you want the chance that a defective part came from that machine. Bayes' theorem reverses the condition:
where the denominator comes from total probability. In words: the path through that ends in , divided by all paths that end in .
The frequency table: the safest route
Formulas with several decimals are where marks are lost without a calculator. Instead, imagine a round number of cases, such as 1000 or 10 000, chosen so that every count is a whole number, and fill in a table.
| not | Total | ||
|---|---|---|---|
| Total |
Fill the row totals from , then each cell from the conditional rates, then the column total. Every conditional probability is now a cell divided by a total: divides by a row total, divides by a column total. The same table also gives the joint and the overall rates, so one table answers every part of a multi-part question.
Base rates matter
When one group is much larger than the other, a small error rate in the large group can produce more cases than a large rate in the small group. That is why a test that is right 90% of the time can still produce mostly false alarms when the thing it detects is rare. A table makes this visible at once; intuition usually does not.
A routine for Bayes questions
- Name the cases (the rows) and the observed event (the column).
- Pick a total such as 1000 so the counts are whole.
- Fill the rows, then the event column.
- Divide the cell you want by the column total of the observed event.
- Check: the probabilities of all cases given the event add up to 1.
Worked examples
Example 1: Reading conditional probabilities from a table
A university club has 200 members: 120 study economics and 80 study law. Of the economics students, 30 play a team sport; of the law students, 40 do. A member is chosen at random. Find and .
Complete the table. Economics: 30 sport, 90 no sport. Law: 40 sport, 40 no sport. Sport total: ; no sport: ; grand total .
: restrict to the 70 who play sport; 40 of them study law. .
: restrict to the 80 law students; 40 play sport. .
Formula check: and , so .
Answer
and . Dividing by the whole club, , gives the joint probability, which answers neither question.
Example 2: Three suppliers
A shop buys 50% of its light bulbs from supplier A, 30% from B and 20% from C. The proportions of faulty bulbs are 2% for A, 3% for B and 5% for C. (a) What proportion of all bulbs is faulty? (b) A bulb is found to be faulty; what is the probability that it came from C?
(a) Total probability: .
(b) Bayes: the path through C ending in "faulty" is , out of for all faulty paths. .
Frequency check with 1000 bulbs: A supplies 500, of which 10 are faulty; B supplies 300, of which 9 are faulty; C supplies 200, of which 10 are faulty. Faulty in all: 29, so 2.9%; from C: .
Final check: .
Answer
(a) 2.9% of bulbs are faulty; (b) , about 0.34. Answering 0.2 (C's share of all bulbs) or 0.05 (C's fault rate) ignores the information that the bulb is faulty.
Example 3: A filter that flags emails
Of the emails reaching an inbox, 20% are spam. A filter flags 90% of spam emails and also, wrongly, flags 5% of genuine emails. An email has been flagged. What is the probability that it is spam?
Cases: spam and genuine. Observed event: flagged. Take 1000 emails.
Spam: 200 emails, of which are flagged. Genuine: 800 emails, of which are flagged.
Flagged in all: . .
Formula check: .
Answer
, about 0.82. The tempting answer 0.9 is , the reverse condition; it ignores the 40 genuine emails that are flagged too.
Common traps
Reversing the condition
"90% of spam is flagged" is . The question "how likely is a flagged email to be spam?" asks for . They share a numerator but not a denominator. Underline the word after "given" or "among": that group is the denominator.
Dividing by the whole population
A conditional probability divides by the size of the condition. Dividing a cell by the grand total gives the joint probability , which a multiple-choice question may well include among its options.
Ignoring the base rate
Comparing only the rates (2% against 6% faulty, say) and answering forgets how much each source produces. Each rate must be weighted by the size of its group, which is exactly what the frequency table does.
Assuming independence
holds only for independent events. When a question gives conditional rates that differ between groups, the events are dependent, and you must multiply by the conditional probability: .
Check yourself
Answer each question before you open its answer.
Question 1: Managers who work remotely
Conditional probability and Bayes
At a firm, 60% of staff work remotely at least one day a week. Among remote workers, 25% are managers; among the other staff, 10% are managers. A manager is chosen at random. What is the probability that this manager works remotely at least one day a week?
- A.
- B.
- C.
- D.
Show the answer
Answer: D.
Working
Take 1000 staff. Remote: 600, of whom 150 are managers. Others: 400, of whom 40 are managers. Managers in all: 190. . Formula check: .
Why the other options are wrong
- A. This is , the probability that a randomly chosen employee is a remote manager. It still has to be divided by the probability of being a manager.
- B. This is , the reverse of the condition asked for.
- C. This is the share of remote workers among all staff; it ignores the information that the person chosen is a manager.
What carries over
Bayes questions become easy with 1000 imagined cases: divide the cell you want by the total of the observed group.
Question 2: Given a sum of 8
Conditional probability and Bayes
Two fair dice are rolled and the sum is 8. Given this, what is the probability that at least one die shows a 6?
- A.
- B.
- C.
- D.
Show the answer
Answer: D.
Working
The reduced sample space is the 5 ordered pairs with sum 8: . Two of them contain a 6. . Formula check: .
Why the other options are wrong
- A. This is , the probability of "sum 8 and a 6 showing" among all 36 outcomes; the condition was not used to shrink the sample space.
- B. This is the probability of at least one 6 with no condition at all; knowing the sum is 8 changes it.
- C. Lists the unordered results {2, 6}, {3, 5}, {4, 4} as if equally likely. In ordered pairs, {2, 6} happens two ways and {4, 4} only one.
What carries over
Given an event, list only the outcomes inside it, still as equally likely ordered outcomes.
Question 3: Which machine made it?
Conditional probability and Bayes
Machine X makes 70% of a factory's items, and 2% of its items are defective. Machine Y makes the other 30%, and 6% of its items are defective. An item picked at random is defective. What is the probability that machine Y made it?
- A.
- B.
- C.
- D.
Show the answer
Answer: C.
Working
Take 1000 items. X makes 700, of which 14 are defective; Y makes 300, of which 18 are defective. Defective in all: 32. . Formula check: .
Why the other options are wrong
- A. This is , the probability that a random item is both from Y and defective; it is not divided by the probability of being defective.
- B. This is Y's share of all output. It ignores the fact that the item is known to be defective, which makes Y more likely.
- D. This is , which compares only the defect rates and ignores that X makes more than twice as many items as Y.
What carries over
Weight each defect rate by its machine’s share of output before comparing them.
Key points
: the condition is the denominator.
and are different numbers; name the group you are restricted to.
Total probability adds every path that ends in the event; Bayes divides one such path by their sum.
Check every Bayes answer with a table of 1000 imagined cases.
All questions here are original and written for UniExamer; none comes from the test maker.
Written by the UniExamer team with AI assistance. Every worked example and check question was re-solved by an independent checker before publication. No subject expert has reviewed this lesson yet. If you find a mistake, write to support@uniexamer.com.