applets.

First Digits

← All apps

About First Digits

In a great deal of real-world data, about 30% of the numbers start with a 1 and fewer than 5% start with a 9. That's Benford's law: the chance that the first digit is d is log10(1 + 1/d), which gives 30.1% for 1, 17.6% for 2, 12.5% for 3, down to 4.6% for 9.

Pick a case file on the left (or paste your own numbers) and the working paper shows how often each first digit turns up, against what the law expects (the red pencil line, labelled Expected). The adding machine switches between the first digit, second digit and first two digits tests, and its slider multiplies every number by anything from 1 to 1,000. The paper tape prints the counts and how well they fit. SPOT THE FAKE puts two simulated expense sheets side by side: one spread the way real expenses are, one made up the way people invent figures.

Each file says what it is. MATHS sets are exact. Physical constants are real (CODATA 2018 values). SIMULATED sets are made up in this page by random sums and say how. Numbers you paste or open stay in this tab: nothing is sent anywhere or stored, and they aren't put in the COPY LINK link.

THE STORY

In 1881 the astronomer Simon Newcomb noticed that in books of logarithm tables the first pages, for numbers starting with 1, were far more worn than the last ones. In a short note in the American Journal of Mathematics he gave the law for the first and the second digit. Hardly anyone took notice.

In 1938 Frank Benford, a physicist at a large American electrical company, noticed the same thing, and tested it on more than 20,000 numbers from 20 different sources, from the areas of rivers and town populations to physical constants and street addresses. His paper, The Law of Anomalous Numbers, made it famous, so it carries his name (a neat case of a law named after its second discoverer).

In 1961 Roger Pinkham showed that if there is any law for first digits that doesn't depend on the units you measure in, it must be this one. In 1995 Theodore Hill proved a more general version and showed why mixing numbers from many different sources tends to produce it.

In the 1990s the accountant Mark Nigrini showed how auditors could use digit tests, and they are now one of the checks some auditors and tax inspectors run on large sets of accounts: people inventing figures tend to spread their first digits too evenly. A misfit is only a reason to look closer, never proof: plenty of honest data doesn't follow the law (see below), and statisticians have warned that it is a poor test for vote counts.

WHY IT HAPPENS

Benford's law holds for numbers spread evenly on a logarithmic scale across several powers of ten. On a log ruler from 1 to 10, the stretch from 1 to 2 takes up 30.1% of the length, while 9 to 10 takes only 4.6%. The ruler strip under the chart shows each number moved into the 1-to-10 range (36,000 becomes 3.6, 0.0072 becomes 7.2) and placed on that ruler.

Things that grow by multiplying (money with interest, populations, anything with a percentage change) end up spread like that. So do sequences like powers of 2 and the Fibonacci numbers: each step multiplies by about the same amount, and as that amount's logarithm is irrational (true of 2, and of any whole number that isn't a power of ten) the numbers creep round the ruler evenly; with ×√10, whose logarithm is ½, they would only ever land on two spots. Multiplying everything by a constant, say changing pounds to dollars or metres to feet, just slides the whole set along the ruler. If the numbers cover the ruler evenly, that changes nothing, which is why the bars barely move when you drag the slider. That is scale invariance.

It fails when numbers are confined to a narrow range (adult heights, all between about 140 and 200 cm), are assigned rather than measured (phone numbers, ID numbers), or are chosen by people (prices like £9.99). The Adult heights and Made-up amounts files show it; move the slider on Adult heights and the bars jump about.

HOW IT WORKS

Digits are read from the numbers as written, so 21000 (302 digits) and 0.00345 are read exactly. Leading zeros are skipped, so 1.2 has the second digit 2 and 0.00345 has 4; a number with only one digit as written (7, 0.003) has no second digit, so it's left out of the second-digit and first-two tests. When you multiply, each number's logarithm is moved along instead.

The fit uses the mean absolute deviation (MAD): the average gap between the share for each digit and the Expected share. The bands (close fit, acceptable, marginal, doesn't fit) are Nigrini's. They're meant for big files, so below 300 numbers the verdict comes from a chi-squared test instead (could fit, or doesn't fit). When some digits would expect fewer than 5 numbers its p-value is found by drawing 2,000 sets of the same size that follow the law exactly, and with fewer than 10 numbers the answer is always could fit. The tape prints both. With a very large file the chi-squared p-value flags even tiny gaps, which is why auditors prefer the MAD.

Pasted text: each line is a row; columns are split at tabs, semicolons or commas, otherwise at spaces. Commas inside numbers like 1,234,567 are read as thousands; with semicolons a comma is read as a decimal point. Words, dates and empty cells are skipped, a minus sign or brackets are ignored (the size is what counts), and zeros are left out.

FURTHER WATCHING AND READING

CASE FILES

MATHS
REAL AND SIMULATED

Powers of 2MATHS

W/P B-1 FIRST-DIGIT TEST

ON A LOG RULER · every number moved into 1 to 10 (36,000 → 3.6) and stacked where it lands

TEST
× 1
NUMBERS0 MAD0 CHI² p0 —