Benford's Law Explorer

Pick a set of numbers and compare its leading digits against Benford's law. Then change the units and watch which datasets move.

Loading interactive simulation...

Why the first digit is a 1 nearly a third of the time 🖖

The nine digits are not equally likely because the leading digit is not spread evenly across the values — it is spread evenly across the logarithms. Getting from 1 to 2 means doubling. Getting from 8 to 9 means a rise of 12.5%. A quantity that grows by multiplication therefore spends six and a half times as long with a leading 1 as it does with a leading 9, and log₁₀(2) = 0.301 is exactly the fraction of a decade the stretch from 1 to 2 occupies. Every figure in the law is that one calculation: log₁₀(1 + 1/d), which gives 30.1% for 1 and 4.6% for 9.

Change the units, and see which data was ever going to obey 🖖

Multiplying every value by a constant shifts every logarithm by the same amount, so a set that already spreads its logarithms evenly is unchanged. That is testable here rather than assertable. Take the Fibonacci numbers, convert them as though they were centimetres becoming inches, then miles becoming kilometres: 30.1%, 30.1%, 30.0%, and chi-square never leaves the range 0.03 to 0.19. Now do it to the heights. In centimetres every value starts with 1; in inches 86% start with 6; in feet 96% start with 5. Same people. One caveat worth knowing before you try it: multiplying by a power of ten moves the decimal point and nothing else, so ×100 leaves every dataset exactly where it was, including the ones that fail. It is in the control set on purpose.

The span has to end on a decade, and real data never does 🖖

The usual advice is that the law needs data spanning several orders of magnitude. That advice is right and the reason given for it is not. Spread values evenly by logarithm across exactly one decade and they match the law perfectly — 30.2% leading 1, chi-square 11.3 on five thousand values — and that is not an approximation, because logarithms uniform across a whole decade are Benford by definition. Two, three, four, six and ten decades give chi-square 8.1, 5.0, 4.8, 5.2 and 7.5. All fine. Now set the span to 1.5 decades. Chi-square is 456 and the law is rejected outright, on a wider range than the one that passed. The leftover half-decade counts its low digits twice and nothing balances it. What rescues real data is that the leftover stops mattering as the span grows: the half-decade penalty falls from 4,707 at 0.5 decades to 456 at 1.5, then 191, 101, 57 and 32 by 6.5. Real measurements never stop neatly at a power of ten, so what several orders of magnitude actually buys is a ragged end too small to matter.

Problems solved in full

  1. Expected count and chi-square contribution for 24 of 200 expense claims 6 steps

    An auditor pulls 200 expense claims and finds that 24 of them begin with the digit 1. Is that consistent with Benford's law? Work out the expected count, the contribution to chi-square from that digit alone, and what the whole test would need before you could act.

    1. Start with what the law expects. The probability of a leading 1 is log₁₀(1 + 1/1) = log₁₀ 2 = 0.30103, so out of 200 claims the expected count is 0.30103 × 200.

    2. That is 60.2 claims. The auditor found 24. The shortfall is 36.2 claims, and it is a shortfall in the digit the law says should be commonest by a wide margin.

    3. Chi-square adds one term per digit, each of them (observed − expected)² ÷ expected. For the leading 1 that term is (24 − 60.21)² ÷ 60.21.

    4. (−36.21)² is 1,310.9, and dividing by 60.21 gives 21.77. The whole test has eight degrees of freedom and its 5% critical value is 15.507, so this single digit has already pushed the statistic past rejection on its own.

    5. Which means the arithmetic is finished and the inference is not. Chi-square grows with the sample: the same proportions in 2,000 claims would give a term ten times larger, and a large honest dataset can fail the test on a deviation nobody would call fraud. That is the reason auditors quote mean absolute deviation instead, which does not grow with n.

    6. So the honest reading is that these 200 claims do not have the leading-digit distribution Benford's law predicts. What it is evidence of is a question the digits cannot answer: a company with a £999 approval threshold produces a wall of leading nines for a completely innocent reason, and so does one that reimburses a fixed daily rate.

    Answer

    Expect 60.2 claims starting with 1; 24 were found; that digit alone contributes 21.77 to a statistic whose 5% critical value is 15.507. The test rejects, and rejecting is not the same as detecting. Benford's law is a screen that tells an auditor where to look, and every published use of it in that role — from Mark Nigrini's tax work in the 1990s onward — treats a failure as a reason to open the file rather than a finding about it. The tool prints mean absolute deviation beside chi-square for exactly this reason: switch to a dataset of 5,000 and watch chi-square climb while the deviation barely moves.

  2. A chi-square of 0.2, and why that is the suspicious one 6 steps

    Load the Fibonacci preset. Chi-square reads 0.2 against a 5% critical value of 15.507, so the sequence passes comfortably. Work out how likely a fit that good is, then decide what a very small chi-square should tell an auditor.

    1. Compare the counts first. A thousand Fibonacci numbers put 301 values in the leading-1 bin against the law's 301.03, and the largest disagreement in any of the nine bins is on the digit 7: 56 observed against 57.99 expected. That is not close. It is nearly exact.

    2. Chi-square on eight degrees of freedom has a mean of 8 and a standard deviation of 4. The card rounds to 0.2 and the value behind it is 0.1695, which sits two standard deviations below the mean of a statistic that cannot go below zero.

    3. The lower tail has a closed form here, because eight degrees of freedom makes the incomplete gamma collapse to four terms. No table is needed.

    4. Putting 0.1695 in returns 2.0 × 10⁻⁶. About one sample in half a million fits the law this well. Switch the dataset to the log-uniform sample at the same size, which is the mechanism itself drawn at random, and the card reads 5.6.

    5. The explanation is that the Fibonacci numbers were never a sample. log₁₀ Fₖ is k log₁₀ φ minus a constant, so the leading digits are decided by the fractional parts of the multiples of 0.2089876…, and that number is irrational. Weyl proved in 1916 that such a sequence spreads out evenly.

    6. It also spreads more evenly than randomness manages. The gaps left by a rotation of this kind shrink like log N over N, while N random draws leave gaps of order 1/√N, and chi-square goes as N times the square of that gap. A thousand deterministic terms therefore beat a thousand random ones by a wide margin, and 0.17 is what the margin looks like.

    Answer

    About one in 500,000 under any random model, which makes the fit evidence that this data was not sampled at all. A chi-square test asks one question: is the data further from the law than chance allows? It has no way of saying that data is too close, and the verdict line reads the same for 0.17 as it does for 8.

    For an auditor that inverts the usual reading. A ledger matching Benford to two decimal places has a problem, and it is the problem R. A. Fisher raised about Mendel's pea data in 1936, where the agreement with theory was closer than sampling could produce. Someone who has read about Benford's law and generates digits from it leaves this signature, and it is easier to see than the fraud the test was built for: honest accounts arrive with the ragged edges of a real sample, and a thousand Fibonacci numbers do not.

References (3)

Example problems

  • Fibonacci - The first thousand Fibonacci numbers. 30.1% of them start with a 1 and chi-square is 0.2, which is about as close to the law as a thousand numbers can get. Nothing was fitted; the sequence is what it is.
  • Heights in cm - Two thousand adult heights in centimetres. Every single one starts with a 1, because adults are between about 145 cm and 195 cm and nothing in that range starts with anything else. This is the maximum possible violation, not a near miss.
  • The same heights, in inches - The same two thousand people measured in inches instead. Now 86% start with 6. The people did not change and neither did their heights — only the unit did, and that is the test.
  • Made-up numbers - A thousand numbers of the kind people produce when asked to invent some: digits spread fairly evenly, with 1 chosen least often. Chi-square is 502. This is why the test is used on expense claims.
  • Half a decade wide - Five thousand values spread evenly across half a decade — from 1 to about 3.2. 61% start with a 1 and chi-square is 4,707. Widen the span to one full decade and the same generator matches the law exactly; widen it to 1.5 and it fails again, which is the part nobody mentions.