Benford's-law testing for people who review other people's numbers
You have a year of expense claims, a vendor payment history or a general-ledger export, and too many rows to read. You want to know which handful to pull first. Benford's law gives a principled place to start: in most honest financial data, about 30% of amounts begin with a 1 and under 5% begin with a 9, and invented or manipulated figures tend not to follow that pattern.
Who it is for
- Internal auditors scoping a payables, T&E or purchasing-card review who want a risk-ranked sample rather than a random one.
- Fraud examiners and forensic accountants who need a quick first look at a client's export before deciding whether a full engagement in their usual tools is warranted.
- Bookkeepers, controllers and small-business owners who approve expenses and want to check whether anyone's claims look made up or are held just under the limit that would need a second approval.
- Students and teachers of auditing and data analytics who want to see Nigrini's tests on data without a licence.
What it runs
The tests and their verdict bands follow Mark Nigrini's Benford's Law: Applications for Forensic Accounting, Auditing, and Fraud Detection (Wiley, 2012):
- First-digit, second-digit and first-two-digits tests, each with a Z statistic per digit, the mean absolute deviation (MAD) and Nigrini's conformity verdict, plus chi-square and its p-value.
- Last-two-digits test (on the cents, or on whole numbers of 100 and over), which picks up rounding and invented figures.
- Summation test, which finds first-two-digit bins carried by a few very large amounts.
- Number-duplication test: the exact amounts that repeat most, and who they were paid to.
Two additions that are not in the standard suite:
- Just under an approval limit. You enter your limits (say 5,000 and 10,000). For each, the page counts amounts within 10% below and 10% above. Under a smooth Benford-shaped distribution about 52.5% of that window falls below the limit (the share is ln(1/0.9) / (ln(1/0.9) + ln 1.1)), so a large excess below, tested with an exact binomial tail, is the pattern split purchases and limit-shaving leave.
- A per-group ranking. The first-digit test is run for every vendor, employee or card with enough amounts. Small groups always look worse on MAD because of sampling noise alone, so the ranking subtracts the MAD expected at each group's size, and the p-values are corrected for testing dozens of groups at once (Benjamini-Hochberg). That keeps the one honest vendor with 52 invoices from topping the list by chance.
A worked example
The page's example button loads a made-up expense ledger: 2,400 amounts drawn from a distribution that follows Benford's law, spread over 40 vendors, plus three planted problems. A vendor with 60 invoices between 4,500 and 4,999 under a 5,000 approval limit; 25 copies of the same 1,250.00 reimbursement; and an employee whose 80 claims were made up by hand, mostly starting with 5 to 8. Here is what the tests report on it.
| Test | Result | What it found |
|---|---|---|
| First digit, whole file | MAD 0.0031, close conformity | Nothing. 165 bad rows in 2,565 barely move the whole-file first digit. |
| First two digits, whole file | MAD 0.0019, marginally acceptable | A hint something is off, without saying what. |
| Just under 5,000 | 84 under vs 30 over; 59.9 expected under; p = 2.9 × 10-6 | The limit-shaving vendor. |
| Just under 10,000 | 25 under vs 37 over; p = 0.98 | Nothing, correctly. |
| Number duplication | 1,250.00 appears 25 times | The repeated reimbursement. |
| Per-group ranking (39 groups of 50+) | 2 groups with q < 0.05 | Exactly the shaving vendor and the invented-claims employee; no honest vendor passes the correction. |
| Last two digits | chi-square 281.7 on 99 df | Too many .00, .25 and .50 endings: rounding from the repeated and invented amounts. |
The lesson is the usual one in Benford work: the whole-file first-digit test is a blunt instrument. The tests that look at a specific mechanism (a limit, a repeat, one person's numbers) are the ones that point to records.
When to use something else
- Your data should not follow Benford's law. Assigned numbers (invoice, check or employee numbers), amounts bounded by policy (a per-diem, a meal cap), prices from a list, or anything spanning less than about two orders of magnitude. The page warns when the range or skew of a file looks wrong, but the judgment is yours.
- You have fewer than about 300 amounts. The tests have little power. Read the records instead.
- You need a documented, repeatable audit trail across many tests and data sources. Audit analytics suites such as IDEA, Diligent (formerly ACL) and Arbutus include Benford functions alongside joins, sampling, scripting and logging that this page does not try to replicate.
- You are looking for the same bill paid twice. That is a matching problem, not a digit problem: use the duplicate payment audit.
Privacy
The CSV is read by the page in your browser and is never uploaded. A command-line version reads the same files with the same code (node cli.mjs ledger.csv --threshold 5000,10000) for anyone who would rather keep the data off a browser entirely or script the check.