The taxi cab problem: a witness says the cab was blue. Was it?
The taxi cab problem with 100 cabs: a witness who is right 80% of the time says blue, yet only 12 of the 29 cabs called blue are blue: about 41%.
The taxi cab problem is a classic test of how people weigh evidence. A cab was involved in an accident at night. A witness says it was blue. The witness is right about colours 80% of the time. So is the cab 80% likely to be blue? Most people say yes. Count the cabs and it comes out at about 41%.

What are the rules?
Two facts about the city and one about the witness:
- 85 cabs in 100 are green.
- 15 cabs in 100 are blue.
- The witness names a cab's colour right 80% of the time, whichever colour it is. So they get it wrong 20% of the time: 1 time in 5.
The question is what the witness's "blue" tells you. It's tempting to answer with the witness's reliability, 80%, and forget how few blue cabs there are.

What happens to 100 cabs?
Lay out 100 cabs and play the rules out on every one of them. 100 makes every count whole.
- 15 are blue. The witness is right 80% of the time, so they call 12 of those 15 blue (and 3 of them green).
- 85 are green. The witness is wrong 1 time in 5, so they call 17 of those 85 blue.
In the picture, every cab the witness would call blue sits on a mustard tile.

| Of 100 cabs | Called blue | Called green | All |
|---|---|---|---|
| Blue | 12 | 3 | 15 |
| Green | 17 | 68 | 85 |
| All | 29 | 71 | 100 |
So how likely is the cab really blue?
The witness said blue, so the only cabs still possible are the ones they would call blue. Keep those and drop the rest: 29 cabs. 12 of the 29 are really blue and 17 are green. So the chance the cab is blue is 12 in 29, about 41.4%. Not 80%.

The testimony still matters. Before the witness spoke, the chance of blue was 15 in 100. After, it is 12 in 29, almost three times as likely. It just isn't enough to make blue the better bet.
Why is it so low?
Green cabs are so common that the witness's mistakes about them outnumber the real blue cabs. Being wrong 1 time in 5 about 85 green cabs gives 17 false "blues"; being right 4 times in 5 about 15 blue cabs gives only 12 true ones. Ignoring how common each colour is, the base rate, is called the base rate fallacy, and this problem is the standard example of it.

This is Bayes' rule done by counting: keep the cases that fit the evidence, then count. The formula P(blue | says blue) = 0.8 × 0.15 / (0.8 × 0.15 + 0.2 × 0.85) = 0.12 / 0.29 is the same 12 and 29, written as fractions of 100.
Check it with code
The script counts the 100 cabs with exact fractions, then simulates a million cabs and checks how many of the ones called blue really were blue:
from fractions import Fraction
import random
blue_rate = Fraction(15, 100) # 15 cabs in 100 are blue, 85 are green
right = Fraction(80, 100) # the witness names a colour right 80% of the time
cabs = 100
blue = cabs * blue_rate # 15
green = cabs - blue # 85
blue_called_blue = blue * right # 12
green_called_blue = green * (1 - right) # 17
called_blue = blue_called_blue + green_called_blue
print('cabs called blue:', blue_called_blue, 'blue +', green_called_blue, 'green =', called_blue)
p = blue_called_blue / called_blue
print('chance a cab called blue is blue:', p, f'= {float(p):.1%}')
rng = random.Random(14)
said = said_blue = 0
for _ in range(1_000_000):
is_blue = rng.random() < 0.15
says_blue = is_blue if rng.random() < 0.80 else not is_blue
if says_blue:
said += 1
said_blue += is_blue
print(f'simulated: {said:,} called blue, {said_blue:,} of them blue -> {said_blue / said:.4f} (exact {float(p):.4f})')
Output:
cabs called blue: 12 blue + 17 green = 29
chance a cab called blue is blue: 12/29 = 41.4%
simulated: 288,901 called blue, 119,854 of them blue -> 0.4149 (exact 0.4138)
Try it
Same witness, right 80% of the time, but now half the cabs in the city are blue. The witness says blue. How often is the witness right? Lay out 100 cabs again: how many blue cabs get called blue, and how many green ones?