Benford's Law Analysis for Audit Data
Operator: Abdulla Al Fahad. How tools are built and checked
Benford's Law says that in amounts which grow or mix across orders of magnitude, about 30% start with 1 and fewer than 5% start with 9. Made-up figures and purchases split to stay under an approval limit drift away from that curve. In the bundled example, a synthetic ledger of 1,800 invoice amounts, 258 start with the two digits 49 where about 16 are expected, and 67 start with 48 against 16 expected; nothing else in the first-two-digit table stands out like that, and the pattern points straight at the 5,000 approval limit. The page runs the first-digit, first-two-digit and second-digit tests on any amount column, reports chi-square, a z-statistic for every digit and the mean absolute deviation (MAD) against Nigrini's conformity bands, and exports the rows behind any digit you flag.
Key features
- First-digit (1 to 9), first-two-digit (10 to 99) and second-digit (0 to 9) tests
- Expected against observed shares in a chart with the 95% band, flagged digits in red, downloadable as SVG
- Chi-square with its p-value, and a z-statistic with continuity correction and a p-value for each digit
- MAD with Nigrini's close, acceptable, marginal and nonconformity bands for the test chosen
- A drill-down listing the rows for any digit, a CSV of the rows behind one digit or all flagged digits, and the digit table as CSV
The three digit tests, Nigrini's MAD bands and why chi-square alone misleads on big files
Load a table and pick the amount column. Amounts accept thousands commas, currency symbols and accounting negatives. Zeros and anything below the minimum you set are skipped (default 10), negatives count by absolute value unless you turn that off, and blanks or text are counted and reported. The two-digit tests use only amounts of 10 and above, because a whole number below 10 has no second digit and would be counted as a 0. At least 30 amounts are needed, and the page warns below 300 for the first digit and 1,000 for the other two.
How it works
The leading digits are read from the decimal expansion of each amount, so 1,234.56 gives 1 and 2, 0.0456 gives 4 and 5, and a bare 7 gives 7 and a placeholder 0. That placeholder is why amounts below 10 are left out of the first-two-digit and second-digit tests, including a decimal such as 3.14 whose second digit is real; with the default minimum of 10 this never arises, and the first-digit test keeps everything that passes the minimum. Benford's expected share of first digit d is log10(1 + 1/d). For the first two digits dd it is log10(1 + 1/dd), and for the second digit it is the sum of that over all nine possible first digits, which gives 11.97% for 0 falling to 8.50% for 9.
For each digit the z statistic is the gap between observed and expected share, less 1 / (2n), divided by the square root of expected times one minus expected over n, as in Nigrini's text. A digit with |z| above 1.96 is flagged. Chi-square sums (observed - expected count)^2 / expected count over the digits, with 8, 89 or 9 degrees of freedom. MAD is the average of the absolute gaps between observed and expected shares. Nigrini's upper limits for the first digit are 0.006 (close), 0.012 (acceptable) and 0.015 (marginal), for the first two digits 0.0012, 0.0018 and 0.0022, and for the second digit 0.008, 0.010 and 0.012; above the last is nonconformity.
Common use cases
- An internal auditor screening a year of 1,800 accounts-payable invoices before choosing which vendors to sample, with the cluster just under 5,000 as the lead.
- A forensic accountant testing expense claims for invented receipts, using the second-digit test, which people who make up numbers often fail even when they avoid obvious first digits.
- A finance analyst checking whether a general-ledger extract of 40,000 lines looks naturally generated, and reading MAD rather than chi-square because at that size chi-square flags tiny departures.
- A tax reviewer comparing the first-digit shares of reported revenue for one filer against Nigrini's 0.006 and 0.012 limits.
How to use this tool
- Drop the ledger extract, choose the amount column and set the smallest amount to include and whether negatives count.
- Read the three conformity cards, then pick the test whose chart you want.
- Look for red bars and the digits with the largest z in the table.
- Choose a flagged digit under Drill into a digit and export its rows for follow-up.
Example
Invoice amounts, minimum 10, negatives by absolute value (first rows of 1,800)
invoice_id,vendor,amount
INV-1001,Delta Courier,4963.03
INV-1002,Fathom Consulting,4965.12
INV-1003,Apex Tools,160.08Results
First digit: MAD 0.0356 (nonconformity), chi-square 531.0 on 8 df; digit 4 is 25.7% against 9.7% expected, z = 23.0
First two digits: MAD 0.0043; 49 appears 258 times against 15.8 expected, z = 61.1; 48: 67 against 16.1, z = 12.6
Second digit: MAD 0.0296; digit 9, z = 20.2Tips for best results
- Start with the first-two-digit chart and its largest z values. It has 90 bars, so a spike at one number such as 49 is easier to see than a modest tilt of a first-digit bar.
- On large files lean on MAD. Chi-square grows with the number of rows, so a harmless 0.1% drift in a 500,000-line ledger gives a tiny p-value while MAD stays inside the close band.
- Drill into the digit, then sort the exported rows by vendor and date. A cluster of one vendor, or of one approver, is far more informative than the digit counts alone.
Common pitfalls
Nonconformity is a reason to look, not proof of fraud. Price points (many items at 9.99), thresholds, fixed fees and rounding policies all bend the digits.
Benford's Law applies to amounts that span several orders of magnitude and arise from growth or mixing. It does not apply to assigned numbers such as invoice or phone numbers, nor to data confined to a narrow range such as heights.
At about 1,500 amounts, ordinary Benford-distributed data can land near the edge of the bands: removing the 49xx cluster from the example (amounts from 4,880 to 4,998) leaves 1,496 amounts with a first-two-digit MAD of 0.0021, already in the marginal band. Use the p-values and the chart as well as the label.
Splitting one ledger into departments cuts the sample sizes, and the smaller subsets conform less tidily by chance alone.
Common errors and how to fix them
- Only 12 usable amounts in "amount". Benford tests need at least 30, and 300 or more to mean much.
- After skips, too few amounts remain. Lower the minimum, check that the right column is chosen and that it holds numbers.
- Enter the smallest amount to include as a number of 0 or more.
- The minimum field has text or a negative value. Type a number such as 10.
Reference values and the conformity cards
The first-digit shares are 30.1, 17.6, 12.5, 9.7, 7.9, 6.7, 5.8, 5.1 and 4.6 percent, and the second-digit shares run 11.97, 11.39, 10.88, 10.43, 10.03, 9.67, 9.34, 9.04, 8.76 and 8.50 percent; the page produces exactly these. Chi-square critical values at 5% are 15.51 for 8 degrees of freedom, 112.02 for 89 and 16.92 for 9.
The three cards at the top use Nigrini's limits for each test, so the same MAD can be close on one test and nonconforming on another. In the example the first-digit MAD of 0.0356 is more than twice the 0.015 limit, and the first-two-digit MAD of 0.0043 is about twice its 0.0022 limit.
Frequently asked questions
Why are amounts below 10 left out of the two-digit tests?
A whole amount such as 7 has no second digit; the page would read it as 70, so every small whole number would pile into the 70 bar and the 0 bar of the second-digit test. Keeping those two tests to amounts of 10 and above avoids that, at the price of also dropping decimals below 10 such as 3.14, which has a real second digit. The first-digit test keeps all amounts that pass your minimum.
How do I know the numbers are right?
Two checks you can repeat. The shares the page compares against are exactly Benford's log10(1 + 1/d) values. And the first 1,000 Fibonacci numbers, a classic Benford sequence, give MADs of 0.0008 on the first digit, 0.0006 on the first two digits and 0.0020 on the second digit (the last two over the 994 numbers of 10 or more), all in the close band.
Should I include negative amounts such as credit notes?
Counting them by absolute value is the default and suits most ledgers. Turn it off to test positive amounts only, which is cleaner when credits are corrections of earlier lines rather than independent amounts.