Thought Toys · Chance & inference · Exhibit 39

Zipf's law

Two curves that look like the same steep drop-off on ordinary axes. Only one of them is actually a power law — and the only honest way to tell which is to change how you draw the axes.

Two panels of the same rank-frequency data. The first uses ordinary linear axes, where the two candidate data sources look similarly steep. The second uses logarithmic axes on both rank and frequency; a true power law becomes a straight line on these axes, while a matched exponential decay visibly curves away from a straight line.

Linear axes — rank vs. frequency

Log-log axes — same data, logarithmic rank and frequency databest-fit line

Log-log fit: slope — · R² —

your turn — switch to exponential decay and compare the log-log panel

What you're seeing

Rank N items by how often they occur — the most common word in a book, the biggest city in a country, the most-visited page on a site — and plot frequency against rank. Real rank-frequency data often follows Zipf's law: frequency falls off as 1/ranks, a power law — a relationship with no built-in scale; zoom in on any stretch of it and the shape repeats. But a merely steep decay isn't automatically a power law. This toy generates two very different curves — a real power law, and an exponential decay carefully tuned to start and end at the same two points — so on ordinary linear axes (top panel) they look like siblings.

Now look at the bottom panel, where both axes are logarithmic. The power law's points snap onto a straight line, and that line's slope is exactly −s — drag the exponent and watch the fitted slope track it. Switch the source to exponential decay and the same points visibly bow away from their own best-fit line, worst at the two ends. The fitted — how well a straight line explains the points — stays high (often above 0.9) for the power law at any exponent or sample size, and drops for the exponential decay every time, even with a fresh random sample.

This is the whole point of log-log axes: they turn "is this scale-free?" into a shape you can see instead of a shape you have to trust. A plot with unlabeled or ordinary axes can make two structurally different processes look identical — which is exactly the kind of dishonest encoding a chart should never get away with.

The rule, exactly. A power law is freq(rank) = A / ranks so ln(freq) = ln(A) s·ln(rank) — exactly linear in log-log coordinates, slope −s, for any s or sample size. An exponential decay matched to the same endpoints, freq(rank) = A·e−λ(rank−1), is linear in rank, not in ln(rank) — structurally curved on log-log axes. Verified in node (improve/verify/39-zipf.js, 91 assertions): with zero noise the power law's log-log fit is exactly =1 for every tested exponent and sample size, while the matched exponential's stays below 0.88 — a structural fact, not sampling noise. With realistic noise added to both, the power law's fitted slope still recovers s and its stays above 0.85, while the exponential's is always at least 0.05 lower than the power law's under the same noise, at every tested (s, N) pair — and the gap does not shrink as N grows from 20 to 160. Counter-example: that structural R² gap survives even with zero randomness, proving log-log straightness distinguishes the two data sources by shape alone, not by luck of the draw.

Also in Chance & inference: Benford's law →

All 16 in Chance & inference
  1. 05The Galton board
  2. 06The Monty Hall problem
  3. 09Bayes' theorem
  4. 13Buffon's needle
  5. 14The central limit theorem
  6. 28Simpson's paradox
  7. 30Markov chains
  8. 31Averages that never settle
  9. 35The birthday paradox
  10. 38The drunkard's walk
  11. 39Zipf's law — you are here
  12. 40Benford's law
  13. 42The coupon collector's problem
  14. 48The wisdom of crowds
  15. 52Genetic drift
  16. 63The gaps are chaos. The count is law.

← the cabinet · Thought Toys — a cabinet of explorable explanations. Exhibit 39.