← Today's challenge

CONDITIONAL PROBABILITY · 8 MIN READ

Bayes’ theorem explained with a probability table

Bayes’ theorem updates a probability when you learn new evidence. The common trap is ignoring how rare the event was before the evidence arrived.

The quick answer

Bayes’ theorem tells you how likely a hypothesis is after some evidence, given how likely the evidence would be under competing possibilities:

P(A | B) = P(B | A) × P(A) / P(B)

Here, A is the event we care about and B is the observed evidence. The denominator P(B) includes all ways that evidence can occur, not only the way involving event A.

A concrete example: screening 10,000 items

Imagine a fictional quality-control system: 1% of manufactured items are defective. A test catches 95% of defective items, but also incorrectly flags 10% of non-defective items. If an item is flagged, what is the probability it is actually defective?

Use a group of 10,000 items to make the base rates visible.

Expected test results among 10,000 items
Actual statusFlaggedNot flaggedTotal
Defective955100
Not defective9908,9109,900
Total1,0858,91510,000

The test flagged 1,085 items in total. Only 95 of those were actually defective. Consequently:

P(defective | flagged) = 95 / 1,085 = about 8.76%

A 95% detection rate does not mean that 95% of positive results are true positives. The base rate matters enormously.

The same calculation using the formula

Let D mean defective and + mean flagged. With prevalence P(D) = 0.01, detection probability P(+ | D) = 0.95, and false-positive rate P(+ | not D) = 0.10:

P(D | +) = (0.95 × 0.01) / [(0.95 × 0.01) + (0.10 × 0.99)]

= 0.0095 / 0.1085 ≈ 0.08756

The bracketed denominator is the law of total probability: it accounts for both true positives and false positives.

A reusable four-step method

  1. Identify the thing you want to know: P(hypothesis | evidence).
  2. Write the starting probability of that hypothesis, also called the prior.
  3. Calculate the chance of the evidence in every relevant group.
  4. Divide the joint probability of the hypothesis and evidence by the overall probability of the evidence.

Common traps in quant problems

  • Reversing the condition: P(flagged | defective) and P(defective | flagged) are different quantities.
  • Ignoring false positives: Even a low false-positive rate can dominate when the true event is rare.
  • Using percentages without a common population: A table with 1,000 or 10,000 imagined cases can often make the calculation clearer than symbols alone.

Try it yourself

A fictional detector flags 80% of faulty components and 10% of healthy components. If 3% are faulty, what fraction of flagged components are faulty?

Reveal the worked answer

The chance of a true positive is 0.03 × 0.80 = 0.024. The false-positive chance is 0.97 × 0.10 = 0.097. Thus the answer is 0.024 / (0.024 + 0.097) = 24/121 ≈ 19.83%.

For the formal law of total probability and Bayes’ theorem, see OpenStax’s probability-theory chapter. These numbers are fictional teaching examples, not claims about any real medical test or product.