INAIO Guide Stage 1 8Probability
8.4 Total probability and Bayes
Split an event into cases with total probability, then reverse the condition using Bayes' theorem.
In Module 8.3, we asked: among the flagged items, how many are faulty? The table already told us how many items were flagged, so we could divide directly. Often a question gives different information: how common faults are, how often a faulty item is flagged, and how often a sound item is falsely flagged. It does not tell us the total number of flags. We must find that total before we can ask the same “among the flagged” question.
That is the purpose of total probability and Bayes' theorem. First account for every way a flag can occur. Then use the flagged group as the new denominator and ask what share came from the cause we care about. The direction reverses: a flag rate given a faulty item helps us find the fault rate given a flag.
This is intermediate probability. Review conditional probability first; Penn State's STAT 414 Bayes lesson develops the same two-step calculation.
A basic idea: find the flagged group, then look inside it
Imagine items. Only are faulty, so are faulty and are sound. A sensor flags of the faulty items and of the sound ones. We can now build the missing flagged group:
- Of the faulty items, are flagged. These are true positives.
- Of the sound items, are flagged. These are false positives.
- There are flagged items altogether. Among those 585, only are faulty, so the chance of a fault given a flag is .
This is the same conditional-probability question as in Module 8.3; we just had to construct its denominator first. The detection rate describes flags among faulty items. The answer describes faults among flagged items. The result is much smaller because sound items are far more common, so even a false-flag rate produces many flags.
The starting fault rate is called a prior: what we knew before seeing the sensor result. The fault chance after seeing a flag is the posterior. Use Next in the animation to follow the two source groups into one flagged pool, then measure the faulty share of that pool.
A quick tour of formulas
Let mean “faulty” and mean “flagged.” From Module 8.3, the reversed question is . We know neither count directly, but the multiplication rule from Module 8.2 gives . To find the denominator, total probability adds the two separate ways to get a flag:
Substituting these pieces gives Bayes' theorem: the faulty-and-flagged route is the numerator, and all flagged routes form the denominator.
More generally, suppose are non-overlapping cases that cover every possibility. Such cases form a partition. For an observed event with , the same two steps are
Check that the cases cover every possibility without overlap. If the denominator is zero, the conditional probability is undefined. The detection rate asks about flags among faulty items; the posterior asks about faults among flagged items.
Application 1: a rare-condition sensor
One in 100 items is faulty. A sensor flags 90% of faulty items and 5% of sound items. What fraction of flagged items are actually faulty? (Compare Module 8.3.)
- , , and .
- Total probability gives .
- Bayes gives .
The 90% detection rate is not the answer. The low fault rate produces many more sound items that can be falsely flagged.
As a count check, among items the animation finds flagged faulty items and flagged sound items. Thus , the same posterior.
Application 2: two factories
Factory A supplies 60% of lamps and has a 2% defect rate. Factory B supplies 40% and has a 5% defect rate. A lamp is defective. What is the chance it came from B?
- .
- The B-and-defective route is .
- .
Although B supplies fewer lamps, it accounts for 62.5% of defective lamps in this model.
Resources
| Source | Title | Why read it |
|---|---|---|
| Penn State STAT 414 | Bayes' Theorem | Learn partitions, total probability, and posterior probabilities. |
Finished this module? Mark it done.
Comments
Stuck on something, spotted a mistake, or found a resource that helped you? Tell us below.
Loading comments