关于「卡方检验:临界值 15.507、九次 z 检验的虚警与大样本下的必然拒绝」,《本福特定律与流水报销审计》给出的定量结论是什么?

结论:第三章说明九次逐个数字的 z 检验让一千笔诚实记录有 0.3242 的机会被标红,几乎服从定律的数据在一万笔上被卡方拒绝的概率是 0.999。

数据口径:书中参数为示意;全部计算由书中程序生成;本书不是法律意见,也不是个人化经营建议,检验结果只是复核信号。 书中以标注框区分已发表的证据、可运行的 Python 计算(20 段程序)、原典与作者的假说。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 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
查看完整验算程序
# 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))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《本福特首位数定律、账目舞弊检测与代购流水报销卡方审计母典》第 3 章「卡方检验:临界值 15.507、九次 z 检验的虚警与大样本下的必然拒绝」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 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}
}

本书其他章节结论