Conditional probability with a table: change the denominator
Calculate P(flagged | faulty) and P(faulty | flagged) from a small inspection table, then connect them through Bayes’ rule.
Conditional probability restricts the denominator to cases where the condition holds. P(A | B) asks what fraction of B cases also satisfy A. Swapping A and B generally changes the answer because it changes the population being counted.
Consider an invented inspection system applied to 1,000 components. Twenty are faulty. The system flags 18 of those, but also flags 98 of the 980 sound components. This is a small arithmetic example for reasoning about evidence, not a reported inspection benchmark.
Build the full table first
| Actual condition | Flagged | Not flagged | Total |
|---|---|---|---|
| Faulty | 18 | 2 | 20 |
| Sound | 98 | 882 | 980 |
| Total | 116 | 884 | 1,000 |
P(flagged | faulty) = 18/20 = 0.9. Among faulty components, nine out of ten are flagged. But P(faulty | flagged) = 18/116, about 0.155. Among flagged components, most are sound because sound components are much more common in this invented population.
These statements are consistent. The system can find a large fraction of faults while still producing a review queue containing many false alarms. A single sensitivity figure does not describe the queue's composition.
Verify the denominator change
faulty_flagged, faulty_clear = 18, 2
sound_flagged, sound_clear = 98, 882
n = faulty_flagged + faulty_clear + sound_flagged + sound_clear
p_faulty = (faulty_flagged + faulty_clear) / n
p_flag_given_fault = faulty_flagged / (faulty_flagged + faulty_clear)
p_flag_given_sound = sound_flagged / (sound_flagged + sound_clear)
p_flag = p_flag_given_fault * p_faulty + p_flag_given_sound * (1 - p_faulty)
bayes = p_flag_given_fault * p_faulty / p_flag
print(f'P(flagged | faulty)={p_flag_given_fault:.3f}')
print(f'P(faulty | flagged)={bayes:.3f}')
print(f'flagged queue={faulty_flagged + sound_flagged}; true faults={faulty_flagged}')
assert abs(bayes - faulty_flagged / (faulty_flagged + sound_flagged)) < 1e-12
for prevalence in [.02, .20]:
posterior = .9 * prevalence / (.9 * prevalence + .1 * (1-prevalence))
print(f'prevalence={prevalence:.2f} posterior={posterior:.3f}')
Checked output:
P(flagged | faulty)=0.900
P(faulty | flagged)=0.155
flagged queue=116; true faults=18
prevalence=0.02 posterior=0.155
prevalence=0.20 posterior=0.692
Connect the table to Bayes’ rule
Bayes’ rule writes the same count relationship as P(faulty | flagged) = P(flagged | faulty) × P(faulty) / P(flagged). The denominator includes flags from both faulty and sound components. Omitting the sound-component term would artificially remove false alarms from the calculation.
The final two lines hold the class-conditional flag rates fixed and vary the fault prevalence. They illustrate how a different base rate changes the composition of flagged cases. Real deployment changes may also alter the flag rates themselves; the controlled calculation does not establish that a system transfers unchanged between factories.
An unconditional probability uses the entire relevant population. A conditional probability uses only the conditioning group. Neither denominator is inherently more honest: choose the one matching the question and label it.
Keep probability distinct from a decision
Whether to inspect a flagged component depends on inspection cost, missed-fault consequences, available capacity and how evidence was collected. The table alone does not set the operating threshold or justify automatic rejection of components.
The counts also have sampling uncertainty if they come from an actual sample. Our probabilities are exact fractions of an invented table. Estimating future rates requires an appropriate sampling design and uncertainty analysis, not merely printing more decimal places.
Extend the table
Double only the number of sound components while preserving the ten-percent false-positive rate. Predict the change in P(faulty | flagged) before recalculating. Then hold the total number of flags fixed and explain why that represents a different experiment.
The Statistics course develops probability and evidence. Continue with ROC and precision-recall summaries for a ranking-based version of the same denominator issue, or Bernoulli versus binomial distributions to model repeated binary outcomes under explicit assumptions.
References
OpenStax conditional probability — Conditional probability and multiplication rules from an openly available statistics textbook.