What does Benford's Law and Ledger Audits conclude, in numbers, about “The Chi-Square Test: the Critical Value 15.507, the False Alarms of Nine z Tests and Certain Rejection in Large Samples”?
Answer: Chapter 3 shows that nine per-digit z tests give a thousand honest records a 0.3242 chance of being marked, and that data almost following the law are rejected by chi-square at ten thousand rows with probability 0.999.
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.3242
| chi-square df 8: 5% critical 15.507, 1% critical 20.090 | |||
| check: P(chi2 > 15.507) = 0.0500 | |||
| N | min E cnt | chi2 size | any-z size |
| 30 | 1.37 | 0.0510 | 0.1918 |
| 50 | 2.29 | 0.0508 | 0.2067 |
| 100 | 4.58 | 0.0490 | 0.2525 |
| 300 | 13.73 | 0.0515 | 0.2875 |
| 1000 | 45.76 | 0.0512 | 0.3242 |
| independent-test bound 1 - 0.95^9 = 0.3698 |
Show the full program
# Chapter 3. p31: chi-square critical values and the real false-alarm rate.
# Exact: the chi-square CDF with 8 degrees of freedom through the
# regularized lower incomplete gamma function (series and continued
# fraction), critical values by bisection. Monte Carlo (fixed seed):
# samples drawn from Benford itself, N first digits each, 4000 samples
# per N; we count how often (a) the chi-square test at 5 percent and
# (b) at least one of nine per-digit z tests at 5 percent cries fraud.
# z uses the continuity correction 1/(2N) of the auditing literature.
import math
import random
P1 = [math.log10(1 + 1 / d) for d in range(1, 10)]
CUM = [math.fsum(P1[:i + 1]) for i in range(9)]
rng = random.Random(20261112)
def gamma_p(a, x):
if x <= 0:
return 0.0
lead = math.exp(-x + a * math.log(x) - math.lgamma(a))
if x < a + 1:
terms, t, k = [1.0 / a], 1.0 / a, 0
while t > 1e-17:
k += 1
t *= x / (a + k)
terms.append(t)
return lead * math.fsum(terms)
b, c, d = x + 1 - a, 1e300, 1 / (x + 1 - a)
h = d
for i in range(1, 400):
an = -i * (i - a)
b += 2
d = an * d + b
d = 1 / (d if abs(d) > 1e-300 else 1e-300)
c = b + an / c
c = c if abs(c) > 1e-300 else 1e-300
h *= d * c
if abs(d * c - 1) < 1e-16:
break
return 1 - lead * h
def chi2_cdf(x, df):
return gamma_p(df / 2, x / 2)
def chi2_crit(alpha, df):
lo, hi = 0.0, 200.0
for _ in range(200):
mid = (lo + hi) / 2
if 1 - chi2_cdf(mid, df) > alpha:
lo = mid
else:
hi = mid
return (lo + hi) / 2
c05, c01 = chi2_crit(0.05, 8), chi2_crit(0.01, 8)
print("chi-square df 8: 5%% critical %.3f, 1%% critical %.3f" % (c05, c01))
print("check: P(chi2 > %.3f) = %.4f" % (c05, 1 - chi2_cdf(c05, 8)))
print("%6s %10s %10s %12s" % ("N", "min E cnt", "chi2 size", "any-z size"))
for n in (30, 50, 100, 300, 1000):
hit_c = hit_z = 0
for _ in range(4000):
cnt = [0] * 9
for d in rng.choices(range(9), cum_weights=CUM, k=n):
cnt[d] += 1
chi = math.fsum((cnt[i] - n * P1[i]) ** 2 / (n * P1[i])
for i in range(9))
hit_c += chi > c05
for i in range(9):
se = math.sqrt(P1[i] * (1 - P1[i]) / n)
z = (abs(cnt[i] / n - P1[i]) - 1 / (2 * n)) / se
if z > 1.96:
hit_z += 1
break
print("%6d %10.2f %10.4f %12.4f"
% (n, n * P1[8], hit_c / 4000, hit_z / 4000))
print("independent-test bound 1 - 0.95^9 = %.4f" % (1 - 0.95 ** 9))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 3: The Chi-Square Test: the Critical Value 15.507, the False Alarms of Nine z Tests and Certain Rejection in Large Samples. 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 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
- Chapter 8 · Closing the Loop: Self-Audit of Buying-Agent Flows and Expense Claims, Red-Light Review and a Pre-Registered Plan