Bayes' Theorem
Reverse conditional probabilities using base rates. Work through a file-classification example with counts and test prior sensitivity.
On This Page
A reversed question needs the base rate
A classifier may often flag problematic files without most flagged files being problematic. These statements use different denominators. Bayes’ theorem connects them:
When A and Aᶜ cover all possibilities:
Here P(A) is the prior event probability and P(A | B) the updated probability after observing B. The denominator must be positive. Conditional accuracy figures and a base rate from incompatible populations need not yield a useful real-world estimate.
Worked example: hypothetical file flags
Suppose 1% of files are problematic. A hypothetical checker flags 90% of problematic files and incorrectly flags 5% of other files. These are supplied assumptions, not measurements of a real checker.
Imagine 10,000 files to make the denominators visible:
| Flagged | Not flagged | Total | |
|---|---|---|---|
| Problematic | 90 | 10 | 100 |
| Other | 495 | 9,405 | 9,900 |
| Total | 585 | 9,415 | 10,000 |
There are 90 true flags and 495 false flags. Among all 585 flagged files, the problematic share is 90/585 ≈ 0.1538, or 15.38%.
The same calculation using probabilities is 0.90 × 0.01 / [0.90 × 0.01 + 0.05 × 0.99]. The 90% detection rate is P(flag | problem); the 15.38% updated probability is P(problem | flag). They are not interchangeable.
The 5% false-positive rate is conditional on nonproblematic files, not on all flags. Here the false share among flags is 495/585 ≈ 84.62%.
Change the prior and watch the posterior change
If the problematic proportion were 10% while the two conditional flagging rates stayed the same, the updated probability would be:
The higher prior increases the share of flags that are true. Keeping conditional rates fixed is itself an assumption: performance may change across populations or file types. Use a sensitivity analysis rather than assuming a single prior is universally correct.
Updating does not by itself make a decision
A decision threshold depends on the consequences of overlooking a problem and reviewing an ordinary file. Posterior probability and action are related but different. A flag does not establish certainty, and an unflagged file is not necessarily safe.
Multiplying evidence from repeated flags requires a model of their dependence. Two checkers built on the same signals may contribute much less independent evidence than a naive product assumes.
The site’s Bayes calculator handles this two-event update from supplied probabilities. Learning an unknown success probability from data uses a richer Bayesian model.
Practice
If P(A) = 0.2, P(B | A) = 0.8 and P(B | Aᶜ) = 0.1, find P(A | B).
Show the explanation
P(B) = 0.8 × 0.2 + 0.1 × 0.8 = 0.24. P(A | B) = 0.16/0.24 = 2/3. The full probability of B, not just its contribution from A, is the denominator.
Reference
OpenStax presents the rules connecting joint and conditional probabilities. The file example is hypothetical.
Did this explanation help?
Your response helps us identify lessons that need more work.