What does Benford's Law and Ledger Audits conclude, in numbers, about “Closing the Loop: Self-Audit of Buying-Agent Flows and Expense Claims, Red-Light Review and a Pre-Registered Plan”?
Answer: Chapter 8 gives a monthly self-audit, a three-light review, the distilled tool (the Ledger First-Digit Auditor) and a pre-registration plan: the gate cuts honest shops' false-alarm rate from 0.4280 to 0.0280 and, with invention at five per cent, lifts the positive predictive value from 0.110 to 0.653. Marked boxes separate published evidence, runnable Python calculations (20 programs), classical sources and the author's hypotheses.
Scope of the numbers: Its parameters are illustrative; all calculations are generated by its programs; the book is not legal advice and not personalised business advice, and test results are only signals for review. Marked boxes separate published evidence, runnable Python calculations (20 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.0280, 0.110, 0.4280, 0.653
| flag rates: broad 0.047, fixed 1.000, capped 1.000, invented 1.000 | |
| honest false-alarm rate: no gate 0.4280, with gate 0.0280 | |
| pi PPV no gate PPV gate honest per hit | |
| 0.01 | 0.023 0.265 42.37 |
| 0.05 | 0.110 0.653 8.13 |
| 0.10 | 0.206 0.799 3.85 |
| 0.20 | 0.369 0.899 1.71 |
| honest per hit = honest shops flagged per invented one, no gate |
Show the full program
# Chapter 8. p83: how many red flags point at an honest shop, by base rate.
# Population of ledgers (300 rows each): a share pi is invented by the
# naive inventor of p21; the honest rest is 60 percent broad ledgers
# (lognormal, median 260, log-sd 1.2) and 40 percent fixed-price or
# capped ledgers (half each, as in p22). The digit test is chi-square
# > 15.507. Rates are estimated on 600 simulated ledgers per type
# (fixed seed). With the gate of p81 the digit test is not run on the
# fixed-price and capped ledgers. PPV = share of flagged ledgers that
# are really invented. All shares are illustrative.
import math
import random
P1 = [math.log10(1 + 1 / d) for d in range(1, 10)]
CUM = [math.fsum(0.6 / 9 + 0.4 * p for p in P1[:i + 1]) for i in range(9)]
N, REPS = 300, 600
rng = random.Random(20261112)
def broad():
return max(1, round(math.exp(rng.gauss(math.log(260), 1.2))))
def fixed():
u = rng.random()
if u < 0.8:
return 990 * rng.choices((1, 2, 3), weights=(6, 3, 1))[0]
return 39 if u < 0.9 else 199
def capped():
return min(200, max(1, round(math.exp(rng.gauss(math.log(120), 0.3)))))
def invented_ledger():
seen, out = set(), []
while len(out) < N:
ds = [rng.choices(range(1, 10), cum_weights=CUM)[0]]
size = rng.choices((2, 3, 4), weights=(3, 5, 2))[0]
for i in range(1, size):
w = [1.0] * 10
w[ds[-1]] *= 0.5
if i == size - 1:
w[0] *= 0.4
w[5] *= 0.4
ds.append(rng.choices(range(10), weights=w)[0])
v = int("".join(str(d) for d in ds))
if v not in seen:
seen.add(v)
out.append(v)
return out
def flagged(xs):
cnt = [0] * 10
for x in xs:
cnt[int(str(x)[0])] += 1
return math.fsum((cnt[d] - N * P1[d - 1]) ** 2 / (N * P1[d - 1])
for d in range(1, 10)) > 15.507
rate = {}
for name, gen in (("broad", broad), ("fixed", fixed), ("capped", capped)):
hits = 0
for _ in range(REPS):
hits += flagged([gen() for _ in range(N)])
rate[name] = hits / REPS
hits = 0
for _ in range(REPS):
hits += flagged(invented_ledger())
rate["invented"] = hits / REPS
print("flag rates: " + ", ".join("%s %.3f" % (k, rate[k]) for k in
("broad", "fixed", "capped", "invented")))
fp_nogate = 0.6 * rate["broad"] + 0.2 * rate["fixed"] + 0.2 * rate["capped"]
fp_gate = 0.6 * rate["broad"]
print("honest false-alarm rate: no gate %.4f, with gate %.4f"
% (fp_nogate, fp_gate))
print("%8s %12s %12s %14s" % ("pi", "PPV no gate", "PPV gate",
"honest per hit"))
for pi in (0.01, 0.05, 0.10, 0.20):
tp = pi * rate["invented"]
a = tp / (tp + (1 - pi) * fp_nogate)
b = tp / (tp + (1 - pi) * fp_gate)
print("%8.2f %12.3f %12.3f %14.2f" % (pi, a, b, (1 - a) / a))
print("honest per hit = honest shops flagged per invented one, no gate")Single source and citation
Fan, Y. (2026). Benford's First-Digit Law, Ledger Fraud Detection and Chi-Square Audits of Buying-Agent Cash Flows and Expense Claims (Version 1.0.0), Chapter 8: Closing the Loop: Self-Audit of Buying-Agent Flows and Expense Claims, Red-Light Review and a Pre-Registered Plan. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-216 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026216,
author = {Fan, Yafu},
title = {Benford's First-Digit Law, Ledger Fraud Detection and Chi-Square Audits of Buying-Agent Cash Flows and Expense Claims},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Where the First-Digit Law Comes From: Uniform Mantissae, Scale Invariance and Multiplicative Chains
- Chapter 2 · The Counterintuitive Claim: Invented Numbers Are Too Clean, and the Law Wrongs Honest Fixed-Price Shops
- Chapter 3 · The Chi-Square Test: the Critical Value 15.507, the False Alarms of Nine z Tests and Certain Rejection in Large Samples
- Chapter 4 · The Mean Absolute Deviation: the Noise Floor, Nigrini's Bands and the First-Two-Digit Test
- Chapter 5 · The Precondition: How Many Decades, Fixed Prices and the Mixing of Price Points
- Chapter 6 · Beyond the First Digit: Last Digits, Repeated Amounts and Piling Up Below an Approval Limit
- Chapter 7 · Chinese and European Sources Weighed: the Four-Pillar Settlement, Newcomb's Logarithm Tables and Pacioli's Trial Balance