Understanding the Benford's law calculator — concept and principle
This calculator tests whether the first digits of your data follow Benford's law. It counts leading digits 1–9, compares them with the Benford proportions, and reports a chi-square test, a p-value and the mean absolute deviation. Auditors, data journalists and students use it as a quick screen for unusual number patterns.
How it is calculated
Benford proportion P(D) = log₁₀(1 + 1/D), for D = 1 … 9
Expected count = n × P(D)
χ² = Σ (observed − expected)² ÷ expected, with 8 degrees of freedom
Mean absolute deviation (MAD) = average of |observed share − P(D)| over the 9 digits
- The first non-zero digit is used: 0.0372 counts as 3. Zeros are skipped.
- With fewer than about 110 values some expected counts are below 5, and the page warns that the p-value is rough.
The principle
Many data sets that span several orders of magnitude, such as invoice amounts, populations or river lengths, have leading digits that are far from uniform: 1 leads about 30.1 % of the time, 2 about 17.6 %, and 9 only about 4.6 %. One intuitive reason: to grow from a leading 1 to a leading 2 a number must double, while going from 9 to 10 is only an 11 % step, so values that grow by percentages spend longest with small leading digits. Data that are assigned (phone numbers), capped or confined to a narrow range (adult heights) do not follow the law.
Worked example
Default input: 40 sample amounts.
- Leading digits counted: 1 → 19, 2 → 7, 3 → 3, 4 → 3, 5 → 1, 6 → 2, 7 → 2, 8 → 1, 9 → 2 (40 values).
- Share with leading 1 = 19 ÷ 40 = 47.5 %, against 30.1 % expected; the most common digit is 1.
- χ² over the nine digits = 7.268, with 8 degrees of freedom.
- p-value = 0.5081, so no significant difference (p ≥ 0.05).
- MAD = 3.96 percentage points; because n is small, treat the p-value as rough.
How to read the result
A large p-value means the data are consistent with Benford's law; a small one (below 0.05) means they differ by more than chance would usually produce. With very large data sets, even tiny, harmless deviations become "significant", which is why the MAD is also reported. A deviation is a reason to look closer, never proof of fraud: rounding, price points, minimum amounts and the nature of the data all cause legitimate departures.
Common mistakes
- Testing data that should not follow Benford's law, such as IDs or percentages.
- Drawing conclusions from very small samples.
- Treating a significant result as evidence of manipulation.
Frequently asked questions
What does Benford's law say?
In many natural data sets the first digit d appears with probability log₁₀(1 + 1/d), so 1 is most common.
How many data points do I need?
The more the better; with fewer than about 110 values some expected counts fall below 5 and the chi-square test is only approximate.
Does all data follow Benford's law?
No. It needs data spread over several orders of magnitude and not assigned by people.
Sources: E. W. Weisstein, "Benford's Law", Wolfram MathWorld · F. Benford (1938), "The law of anomalous numbers", Proceedings of the American Philosophical Society 78(4)