Math paradoxes

Simpson's paradox 78% vs 83%. Which treatment is better?Better in every group. Worse overall.

Two treatments for kidney stones, 350 patients each. Treatment A succeeds in 78% of cases, treatment B in 83%. Which one would you choose for yourself, or is this not enough to decide? Lock in your answer, then check it against the split by stone size, a table editor and five explanations.

Treatment A works better than treatment B for small kidney stones and for large ones. Put all the patients together, and B comes out ahead. Both statements come from the same numbers. Below you'll see how that happens and which number to trust.

Make a guess
2 of 2groups where A wins
78% < 83%overall: A vs B

Share of successful treatments, data from Charig et al., 1986. Pink marks the winner in each row.

The puzzle

Picture this: you choose the treatment

The classic example of Simpson's paradox comes from a 1986 British study of kidney stone treatments.

Simpson's paradox happens when a trend that holds in every group of data reverses once the groups are combined. The classic example comes from a 1986 British study of kidney stone treatments.

  1. 1

    Two treatments

    Treatment A: open surgery. Treatment B: percutaneous surgery through a small puncture. Each was given to 350 patients.

  2. 2

    The overall result

    Treatment A succeeded in 273 of 350 cases (78%), treatment B in 289 of 350 (83%). At first glance B is better.

  3. 3

    The question

    Which treatment would you choose for yourself, seeing only these overall results? Or is this not enough to decide? Make your pick in round 1, then see what splitting the patients by stone size shows.

  4. 3

    Split by stone size

    Now split the patients into two groups: small stones and large stones. For small stones A gets 93%, B 87%. For large stones A gets 73%, B 69%.

  5. 4

    The question

    How can A be better in each group and worse overall? And which treatment would you recommend to a patient whose stone size you know?

Intuition says

"If A is better for small stones and for large stones, it must be better for everyone together"

It feels obvious, but it is not a rule of arithmetic. The overall rate also depends on how many patients of each kind a treatment got. Treatment A got mostly the hard cases.

What you need to know

  • Patients were not assigned to treatments at random.
  • Doctors chose open surgery more often for large stones.
  • Large stones are harder to treat with any method.

Stone size affects both the choice of treatment and the outcome. Such a variable is called a confounder. More in round 4.

Round 1 · Choose

Which treatment would you choose for yourself?

Imagine you skipped the puzzle above and see only the overall results. Pick a treatment or say the data is not enough, then look at the split by stone size.

Overall results, 350 patients per treatment

Tap your choice.

Hints

Hard to decide? Open the hints one at a time: the easy one first, then stronger ones.

Next: the solution

Next comes the explanation, with spoilers

The next rounds show which method is really better: a table, a simulation and the explanation. Answer round 1 first, or go on?

You chose to always show all rounds.

Round 2 · The 2×2 table

Break the paradox or build your own

The sliders set the number of patients and successes in each cell of the table. The bars on the right update instantly. Try to make the paradox disappear, or pick another example.

Round 3 · Simulation

How often does the paradox happen?

The computer generates thousands of random 2×2 tables and counts the share where one treatment wins in both groups and the other wins overall. The answer depends on how the tables are generated, so there are two different generators here.

reference value for the generator simulation: running share after each batch

Share of tables with the paradox (simulated)
–
Reference
–
Last table found with the paradox

The overall rate slides between the two group rates

Each line shows what a treatment's overall rate would be for a different share of small-stone patients. Line A is above line B everywhere. But the overall rates are points at different places on their lines: A has few easy patients, B has many.

treatment A treatment B
A overall
–
B overall
–

Once you answer, the simulation code appears here so you can run it yourself.

Check it yourself in code

The same simulation, short and with no libraries. Run the JavaScript in your browser console (F12) or in Node; the Python needs only the standard library.

JavaScript
// Random 2×2 tables: all patients are split among 8 cells (group × treatment × success or not) uniformly at random.
// We count the share of tables where one treatment wins in both groups and the other wins overall.
const TABLES = 1000000;

function table() {
  const e = [];
  for (let i = 0; i < 8; i++) e.push(-Math.log(1 - Math.random()));  // normalised exponentials give uniform shares
  // [successes, patients] for A and B in groups 1 and 2; the grand total does not matter
  return [[[e[0], e[0] + e[1]], [e[2], e[2] + e[3]]], [[e[4], e[4] + e[5]], [e[6], e[6] + e[7]]]];
}

let hits = 0;
for (let i = 0; i < TABLES; i++) {
  const [[A1, B1], [A2, B2]] = table();
  const a1 = A1[0] / A1[1], b1 = B1[0] / B1[1], a2 = A2[0] / A2[1], b2 = B2[0] / B2[1];
  const A = (A1[0] + A2[0]) / (A1[1] + A2[1]), B = (B1[0] + B2[0]) / (B1[1] + B2[1]);  // overall: a weighted average of the groups
  if ((a1 > b1 && a2 > b2 && A < B) || (a1 < b1 && a2 < b2 && A > B)) hits++;
}
console.log(`Tables with the paradox: ${(100 * hits / TABLES).toFixed(2)}%`);
console.log(`Exact (Pavlides and Perlman, 2009): 1/60 = ${(100 / 60).toFixed(2)}%`);
Python
# Random 2×2 tables: all patients are split among 8 cells (group × treatment × success or not) uniformly at random.
# We count the share of tables where one treatment wins in both groups and the other wins overall.
import random

TABLES = 1_000_000

hits = 0
for _ in range(TABLES):
    e = [random.expovariate(1) for _ in range(8)]   # normalised exponentials give uniform shares
    a1, b1 = e[0] / (e[0] + e[1]), e[2] / (e[2] + e[3])   # group 1: success rate of A and B
    a2, b2 = e[4] / (e[4] + e[5]), e[6] / (e[6] + e[7])   # group 2
    A = (e[0] + e[4]) / (e[0] + e[1] + e[4] + e[5])      # overall: a weighted average of the groups
    B = (e[2] + e[6]) / (e[2] + e[3] + e[6] + e[7])
    if (a1 > b1 and a2 > b2 and A < B) or (a1 < b1 and a2 < b2 and A > B):
        hits += 1

print(f"Tables with the paradox: {100 * hits / TABLES:.2f}%")
print(f"Exact (Pavlides and Perlman, 2009): 1/60 = {100 / 60:.2f}%")
Round 4 · Five explanations

Why the overall number misleads

The key is that the two treatments were given to different patients. Here are five ways to see it.

In plain wordspictures, analogies, small numbers

“In plain words” is hidden on all puzzles.

A weighted average

The overall rate is a mix of group rates

Only 25% of A's patients had small stones, so its overall rate sits close to its 73% for large stones. For B the share is 77%, so its rate sits close to its 87% for small stones. The different weights outweigh A's advantage.

The confounder

Stone size drives both the choice and the outcome

Stone size Treatment (A or B) Outcome large → more often A large are harder the effect we want Splitting into groups blocks the magenta path

The overall comparison mixes two effects: the real difference between the treatments, and the fact that A more often got the harder patients. Comparing treatments within a group of the same stone size removes the second effect.

Which number to trust

It depends on the question you ask

Effect of a treatment on a patientby groupA wins: 93% vs 87%, 73% vs 69%
What happened to the patients who got each treatmentoverallB: 83%, A: 78%

The data alone do not say which table to use. The causal picture decides. Here stone size affects which treatment is given, so for "which treatment is better for a patient" we use the numbers by group. But if a variable is itself a result of the treatment (say, blood pressure after taking a drug), you should not split by it: then the overall number is the right one.

Rigoroustables, charts, formulas

“Rigorous” is hidden on all puzzles.

Vectors

Steeper arrows, lower finish

Each group is an arrow: right by the number of patients, up by the number of successes. The slope is the success rate. Both of A's arrows are steeper than B's matching arrows. But A has a short steep arrow and a long shallow one, and B has the reverse. So B's path, built head to tail, ends higher. To make the slopes visible, the chart subtracts 70% of the patients from the successes: an arrow with a 70% rate would be flat.

For formula lovers

The law of total probability and standardisation

Rows A and B show that the overall rate is a weighted of the group rates, with each treatment's own weights. The last row gives both treatments the same patient mix, the one in the whole sample (357 small and 343 large). Then the comparison is fair, and A wins. The paradox can only happen when the two treatments have different patient mixes.

Round 5 · Going further

Baseball, dots on a chart and many groups

Simpson's paradox is not just a medical curiosity. Here are three settings: sports statistics, a trend on a chart, and the case with more than two groups. Real data from Berkeley and COVID-19 wait in the next section.

Derek Jeter versus David Justice

Batting average: hits divided by at-bats.

Justice is better in 1995 and in 1996, yet Jeter is better over the two years combined. The reason is the same: in 1995 Jeter had only 48 at-bats, and he spent his better year, 1996, with 582. Justice had it the other way round.

No tables: dots on a chart

The trend flips the same way

The paradox is not only about percentages. Here is made-up data: 60 people, hours of exercise a week and cholesterol level. Older people both exercise more and have higher cholesterol because of their age.

Age plays the part of stone size here: it affects both the "treatment" (how much exercise) and the outcome.

Three groups and more

Here A has the same edge over B in every group. Groups run from easy to hard, and A gets more of the hard patients while B gets more of the easy ones. About 2,000 patients per treatment. Change the number of groups and A's edge.

A relative of this paradox: the Will Rogers phenomenon, where one person moving between groups raises the average of both.

Real data

Real data and you

First check your own numbers for the paradox. Then two real cases where it made the news: university admissions and COVID-19 deaths.

Try it on yourself

Two shops over two months: how many visitors came and how many of them bought. You can use two ads over two weeks or two managers with two kinds of clients instead. These are example numbers; type in your own.

Berkeley, 1973: the six largest departments

Admitted / applied. The group admitted more often is in bold. Departments are named by letters, as in the paper.

Source: Bickel, Hammel, O'Connell, Science 187 (1975) 398–404; the same numbers are in the dataset UCBAdmissions (R).

COVID-19: Italy versus China

Share of confirmed cases who died, by age, early in the pandemic.

Italy, 9 March 2020China, 17 February 2020
China, all ages
Italy, all ages

Source: von Kügelgen, Gresele, Schölkopf, «Simpson's paradox in Covid-19 case fatality rates», arXiv:2005.07180, Table III; data from Istituto Superiore di Sanità and China CDC.

Bonus · At work

Where this shows up at work

Real situations from marketing, analytics, product and business where the same maths applies. Only known data, research and plain calculations you can check.

Product analytics

An A/B test whose traffic split changed

The situation
A new variant is launched carefully: on the first day it gets 1% of traffic, later 50%. And days of the week convert differently.
The trap
The variant can win on every single day and lose in the total over the whole test, because most of its visitors fell on the "weak" days. Microsoft's experimentation team listed this as one of seven common pitfalls of online experiments.
How to plan for it
Don't pool days with different traffic splits into one table. Compute the effect for each period with the same split and weight them, or analyse only the period after the last change of the split.

Source: Crook, Frasca, Kohavi, Longbotham, "Seven Pitfalls to Avoid when Running Controlled Experiments on the Web", KDD 2009.

Performance marketing

Every country gets cheaper, yet the overall CPA rises

The situation
A budget of $10,000 a week. First $8,000 goes to country A at a $10 CPA and $2,000 to the pricier country B at $40. Next week the team pushes into market B: $4,000 in A, $6,000 in B, and both campaigns are 10% better optimised: CPA $9 and $36.
The trap
The overall CPA went from $11.8 to $16.4, up 39%, even though it fell in each country. Anyone looking only at the total will decide the optimisation did harm.
How to plan for it
When the budget split across channels, countries or devices changes, look at the metric within each segment and, separately, at the effect of the new split. The overall CPA answers a question about the mix, not about campaign quality.
Analytics

The median rises while every group falls

The situation
In 2013 New York Times journalist Floyd Norris noticed that since 2000 the median real wage in the US had risen slightly, by about 1%, while in every education group, from school dropouts to college graduates, it had fallen.
The trap
The average rose because of the mix, not the wages: the share of better-paid people with degrees grew over those years. The same happens to average order value, ARPU or conversion when the customer mix changes.
How to plan for it
Before explaining a change in an overall metric, split it in two: what changed within the segments and how the segments' shares changed.

Source: Floyd Norris, "Can Every Group Be Worse Than Average? Yes.", The New York Times, 2013.

Bonus · Fun facts

Things to tell your friends

1951

Named after Simpson

The British statistician Edward H. Simpson described the effect in a 1951 paper on contingency tables. The name "Simpson's paradox" was introduced by Colin Blyth in 1972.

1899 · 1903

Simpson was not the first

Karl Pearson (1899) and G. Udny Yule (1903) described similar effects earlier. That is why it is sometimes called the Yule–Simpson effect.

1973

The Berkeley case

Graduate admissions data from the University of California, Berkeley, for 1973 became the textbook example. The paper by Bickel, Hammel and O'Connell about them appeared in Science in 1975.

700

Kidney stones

The 700-patient example comes from a study by Charig and colleagues, published in the British Medical Journal in 1986. It is now the classic illustration of the paradox in statistics textbooks and courses.

.310

Jeter and Justice

David Justice had a better batting average than Derek Jeter in both 1995 and 1996. Over the two seasons combined Jeter hit .310 and Justice only .270.

2018

The Book of Why

Simpson's paradox is a standard example in causal inference. Judea Pearl discusses it at length in The Book of Why (2018), written with Dana Mackenzie: choosing the right table takes a causal model.

The Art of Statistics

David Spiegelhalter

2019 · chapter 4

The Book of Why

Judea Pearl, Dana Mackenzie

2018 · chapter 6

Dark Data

David J. Hand

2020 · chapter 3

All books →
Discussion

What do you think?

Share your own explanation, an objection or a variant of the puzzle. You need a GitHub account to comment.

Is “School maths” the right level for this puzzle?

Thank you! This helps set the levels right.

Newsletter

New puzzles, explanations and discussions

I keep adding new puzzles, new ways to explain them and write-ups of the discussions they start. Leave your email and I'll write when something new is out. No spam, one-click unsubscribe.

The sign-up form will appear here soon.