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
Nmin E cntchi2 sizeany-z size
301.370.05100.1918
502.290.05080.2067
1004.580.04900.2525
30013.730.05150.2875
100045.760.05120.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