Statistics for Finance
Bayes' rule
A test that's right 99% of the time can still be wrong most of the times it raises an alarm. Bayes' rule shows why, and how to turn what you know into what you want to know.
The alarm goes off
Example, with made-up numbers. A bank's fraud system catches 99% of fraudulent card payments. It also wrongly flags 2% of normal ones. Only 0.1% of payments are fraud. A payment has just been flagged. How likely is it to be fraud? Most people guess around 99%.
The idea
Picture 100,000 payments. The detector is good, but fraud is so rare that the few real cases are swamped by false alarms from the huge number of normal payments:
Of 2,097 flagged payments, only 99 are real fraud. The other 1,998 are false alarms.
So a flagged payment is fraud only 99 ÷ 2,097 ≈ 4.7% of the time. The rarity of fraud before any test, the base rate, matters as much as how good the test is. Bayes' rule puts this into one formula:
Here A is "fraud" and B is "flagged". P(B), the chance of any flag, adds up both routes to a flag: real fraud caught, plus normal payments flagged by mistake.
Quick check
An event is very rare, and a fairly accurate test says it has happened. What's the most likely truth?
Worked example: the formula
| P(flag | fraud) × P(fraud) | 0.99 × 0.001 = 0.00099 |
| P(flag | normal) × P(normal) | 0.02 × 0.999 = 0.01998 |
| P(flag): add the two | 0.02097 |
| P(fraud | flag) = 0.00099 ÷ 0.02097 | 0.0472 |
Two ways to raise it: cut false alarms (at a 0.2% false-alarm rate, it jumps to 33%) or look where fraud is more common (if 1% of payments were fraud, it would also be 33%). Counting with 100,000 imaginary cases, as in the picture, always gives the same answer as the formula, and is easier to explain.
Try it yourself
Change the base rate and the test, and see the real chance.
| Out of 100,000 cases, flagged and real | |
| Flagged but false | |
| Chance a flag is real |
Common mistakes
Three slips beginners make.
- Ignoring the base rate. How common the event is to begin with matters as much as how accurate the test is.
- Swapping the condition. "Catches 99% of fraud" is P(flag | fraud). The question is P(fraud | flag).
- Forgetting false alarms. P(flag) includes every flag, real or not.
Remember
- Bayes' rule: P(A | B) = P(B | A) × P(A) ÷ P(B).
- For rare events, false alarms can swamp real cases, even with an accurate test.
- When in doubt, count it out with 100,000 imaginary cases.
Check yourself
Three questions. Try them without scrolling up.
1. 1% of loans default. A model flags 90% of defaulters and 9% of good loans. What is P(default | flagged), roughly?
2. For a rare event, which change raises P(real | flagged) the most?
3. 2% of firms go bust. 70% of those that did had falling margins the year before. 20% of all firms have falling margins. What is P(bust | falling margins)?
Expected value
The probability-weighted average: what an uncertain bet is worth.