Benford's Law: Definition, Formula and Examples

By Dr. Zubair Khalid, DVM, MS, PhD ·

Benford's Law: Definition, Formula and Examples

Benford's law predicts that in many real-world datasets the leading digit is not evenly distributed. The digit 1 appears about 30.1% of the time, digit 2 about 17.6%, and the frequencies fall steadily down to digit 9 at about 4.6%. You can test any dataset against this expectation with a chi-square goodness-of-fit test, which is what the worked example below does.

Quick Answer

  • Benford's law gives the probability that the first significant digit of a number is $d$, using $P(d) = \log_{10}(1 + 1/d)$ [1].
  • Digit 1 is expected about 30.1% of the time, digit 2 about 17.6%, and digit 9 about 4.6%.
  • It applies to naturally occurring data that spans several orders of magnitude, such as invoice amounts, populations and physical constants [1].
  • You test it with a chi-square goodness-of-fit test comparing observed digit counts to expected counts.
  • A large chi-square value and a small p-value mean the data does not follow Benford's law, which can signal errors or manipulation.

What Benford's Law Means

Benford's law is a statement about the first significant digit of numbers in a dataset. The first significant digit is the leading nonzero digit, so 0.00437 has first digit 4 and 91,200 has first digit 9. The law says these leading digits are not equally likely. Small digits are far more common than large ones.

The precise statistical definition is that the first significant digit $d$, where $d$ is one of 1 through 9, occurs with probability

$$P(d) = \log_{10}\left(1 + \frac{1}{d}\right)$$

The law was first published by Simon Newcomb in 1881. It went unnoticed until Frank Benford, apparently unaware of Newcomb's paper, reached the same conclusion and published it in 1938 with support from large amounts of data [1]. It is also called the first-digit phenomenon [1].

A more general version covers the first several digits together. The probability that the first significant digits are the string $d_1 d_2 \dots d_k$ is $\log_{10}(1 + 1/d_1 d_2 \dots d_k)$ [1]. For example, the probability that a number starts with 12 is $\log_{10}(1 + 1/12)$, which is about 0.0348.

How It Works

The mechanism behind Benford's law is scale invariance. If a dataset follows the law, then changing the units, such as converting dollars to euros or meters to feet, does not change the distribution of leading digits. Only a logarithmically spaced distribution has that property, and the formula above is exactly that distribution.

Here is what each symbol means.

SymbolMeaning
$d$The first significant digit, an integer from 1 to 9
$P(d)$The probability that a number in the dataset starts with digit $d$
$\log_{10}$Base-10 logarithm
$O_d$Observed count of numbers starting with digit $d$
$E_d$Expected count of numbers starting with digit $d$, equal to $n \cdot P(d)$
$n$Total number of values in the dataset
$\chi^2$Chi-square test statistic, $\sum (O_d - E_d)^2 / E_d$
$df$Degrees of freedom, equal to 9 minus 1, which is 8

The expected counts come straight from the probabilities. If you have 200 numbers, the expected count for digit 1 is $200 \times 0.3010 = 60.206$. The chi-square statistic then measures how far the observed counts sit from those expectations. A small statistic means the data is consistent with Benford's law. A large statistic means it is not.

Worked Example

The dataset is the first digits of 200 invoice amounts, a deterministic synthetic sample built for this test.

First digitObserved countExpected count
18060.206
22135.2183
31224.9877
41419.382
51615.8362
61313.3894
72011.5984
81410.2305
9109.1515

The steps run as follows.

  1. Sample size: $n = 200$.
  2. Benford probability for digit $d$: $P(d) = \log_{10}(1 + 1/d)$.
  3. Example for digit 1: $\log_{10}(1 + 1/1) = 0.3010$.
  4. Expected count for digit 1: $200 \times 0.3010 = 60.2060$.
  5. Chi-square statistic: $\chi^2 = \sum (O - E)^2 / E = 28.0594$.
  6. Degrees of freedom: $df = 9 - 1 = 8$.
  7. p-value: $p = 0.0005$.
  8. Critical value at $\alpha = 0.05$: $\chi^2_{crit} = 15.5073$.
  9. Decision: $p = 0.0005$ against $\alpha = 0.05$, so reject $H_0$.

The null hypothesis $H_0$ is that the leading digits follow Benford's law. The alternative is that they do not. Here the statistic of 28.0594 exceeds the critical value of 15.5073, and the p-value of 0.0005 is well below 0.05. The invoice sample does not follow Benford's law.

import numpy as np
from scipy import stats
digits = np.arange(1, 10)
observed = np.array([...])  # your first-digit counts
n = observed.sum()
expected = n * np.log10(1 + 1/digits)
chi2, p = stats.chisquare(observed, expected)  # chi2=28.0594, p=0.0005

Output: chi2 = 28.0594, df = 8, p = 0.0005, critical(0.05) = 15.5073 -> reject H0 at alpha=0.05

How to Interpret It

The p-value answers one question. If the data really followed Benford's law, how likely is a chi-square statistic at least as large as the one you observed? A small p-value means such a result is unlikely under the law, so the data probably does not follow it.

The critical value gives the same decision without a p-value. With 8 degrees of freedom and $\alpha = 0.05$, any statistic above 15.5073 leads you to reject the null hypothesis. In the example, 28.0594 is above that line.

The individual counts tell you where the mismatch lives. In the invoice sample, digit 1 appears 80 times against an expected 60.206, and digit 7 appears 20 times against an expected 11.5984. Those two digits carry much of the deviation. Looking at which digits deviate is often more useful than the single test statistic, because it points to the specific pattern in the data.

When to Use It (and when not to)

Use Benford's law when your data spans several orders of magnitude and comes from a natural or organic process. Invoice totals, expense reports, tax figures, population counts, river lengths and physical constants are common examples. It is widely used in auditing and fraud detection as a screening tool, because fabricated numbers tend to have leading digits that are too evenly spread or too concentrated on digits a person finds plausible.

Do not use it on data with a narrow range. Heights in centimeters, ages, or prices that all sit between 10 and 99 will not follow the law. Do not use it on assigned or sequential numbers, such as invoice numbers, ZIP codes, phone numbers or ID fields, because those are generated by a rule, not by a natural process. Do not use it on data with a hard floor or ceiling, such as a minimum payment of 500, because the truncation distorts the leading digits.

Benford's Law vs the Uniform Distribution

The closest related idea is the uniform distribution, which says every leading digit is equally likely at 1/9, or about 11.1% each. That is the default assumption many people carry without realizing it.

FeatureBenford's lawUniform distribution
Probability of digit 1About 0.3010About 0.1111
Probability of digit 9About 0.0458About 0.1111
ShapeDecreasing, log-basedFlat
Typical dataNaturally occurring, wide rangeRandom digits, assigned codes
Scale invarianceYesNo

If your data follows Benford's law, the uniform distribution is the wrong benchmark and will make normal data look suspicious.

Common Mistakes

  • Testing data that is too narrow in range. If all values fall within one order of magnitude, the law does not apply. Check the spread before you test.
  • Including assigned numbers. Invoice IDs, account numbers and dates are generated by rules. Exclude them and test only the measured amounts.
  • Using the raw value instead of the first significant digit. Strip leading zeros and signs first, so 0.00437 becomes digit 4.
  • Ignoring the sample size. Small samples produce unstable counts. A few hundred values is a reasonable starting point for a chi-square test.
  • Reading a rejection as proof of fraud. A failed test means the data does not follow the law. It does not identify who changed what or why.
  • Forgetting that expected counts must be large enough. Chi-square needs reasonably sized expected counts in each cell, so very small samples are unreliable.

Limitations

Benford's law cannot tell you whether a specific number is fake. It describes a whole dataset, and a dataset that fails the test may simply be the wrong kind of data for the law. A dataset that passes the test may still contain fabricated values that happen to preserve the digit pattern.

The test also depends on choices you make before running it. Which column you test, how you handle zeros and negatives, and how large the sample is all affect the result. Treat a failed test as a signal to look closer at the data, not as a final answer.

Frequently Asked Questions

What does Benford's law predict?

It predicts the frequency of each leading digit in a dataset. Digit 1 should appear about 30.1% of the time, digit 2 about 17.6%, and the probabilities decrease down to digit 9 at about 4.6% [1]. The formula is $P(d) = \log_{10}(1 + 1/d)$.

Why does Benford's law work?

It works because many natural datasets are spread across several orders of magnitude, and the leading-digit distribution of such data is scale invariant. Changing units does not change the pattern, and the log-based formula is the only distribution with that property.

Can I use Benford's law to detect fraud?

You can use it as a screening tool. Fabricated numbers often produce leading-digit patterns that deviate from the law, so a failed test flags a dataset for closer review. It does not prove fraud on its own, and it should be combined with other audit procedures.

What sample size do I need for a Benford's law test?

There is no fixed minimum, but small samples give unstable digit counts and unreliable chi-square results. A few hundred values is a practical starting point, and larger samples give you more confidence in the outcome.

What if my data fails the Benford's law test?

First check that the data is the right type. If it spans a narrow range, contains assigned numbers, or has a floor or ceiling, the law may not apply at all. If the data is appropriate and still fails, examine which digits deviate most and investigate those records.

References

  1. Benford's law

Further Reading

Related Articles