关于「实证闭环:订单台流程、订单校验位生成器与预注册检验」,《校验码代数与韦尔霍夫算法》给出的定量结论是什么?

结论:第八章给出订单台流程、订单校验位生成器与预注册检验方案:单侧检验需 50 条经审计的差错。书中以标注框区分已发表的证据、可运行的 Python 计算(19 段程序)、原典与作者的假说。

数据口径:书中录入量、出错率与成本均为示意参数;全部计算由书中程序生成;本书是非个人化经营建议。 书中以标注框区分已发表的证据、可运行的 Python 计算(19 段程序)、原典与作者的假说。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 50

Aestimate share within +/- 0.03: n = 410 slips, 3.3 months
Bshare > 0.75, exact one-sided: n = 50, reject if >= 43
size 0.0453, power 0.8366
CLuhn vs Verhoeff miss rate: n = 2423 slips per arm
at 125 slips a month: 19.4 months per arm
查看完整验算程序
# Chapter 8. p82: how many logged slips the pre-registered tests need.
# Test A estimates, from the shop's own audit log, the share of slips
# that are single errors or neighbour swaps; Verhoeff's value is 0.8926
# (p11). Test B asks whether that share exceeds 0.75, the level below
# which the book's advice to prefer an anti-symmetric code loses most
# of its edge; the smallest n is found with the exact binomial tail.
# Test C compares miss rates per slip before and after a switch from
# Luhn (0.02072) to Verhoeff (0.01071), full spectrum, from p52.
# Months assume 125 slips a month (p61). alpha 0.05, power 0.80.
import math

Z95, ZB = 1.959964, 0.841621


def binom_tail(n, k, p):
    # P(X >= k),用对数精确求和
    terms = []
    for x in range(k, n + 1):
        lg = (math.lgamma(n + 1) - math.lgamma(x + 1)
              - math.lgamma(n - x + 1) + x * math.log(p)
              + (n - x) * math.log(1 - p))
        terms.append(math.exp(lg))
    return math.fsum(terms)


p = 0.8926
nA = math.ceil(Z95 ** 2 * p * (1 - p) / 0.03 ** 2)
print("A  estimate share within +/- 0.03: n = %d slips, %.1f months"
      % (nA, nA / 125))
p0, p1 = 0.75, p
nB = None
for n in range(10, 400):
    k = next(k for k in range(n + 2)
             if k == n + 1 or binom_tail(n, k, p0) <= 0.05)
    if k <= n and binom_tail(n, k, p1) >= 0.80:
        nB, kB = n, k
        break
print("B  share > 0.75, exact one-sided: n = %d, reject if >= %d"
      % (nB, kB))
print("   size %.4f, power %.4f"
      % (binom_tail(nB, kB, p0), binom_tail(nB, kB, p1)))
q1, q2 = 0.02072, 0.01071
qbar = (q1 + q2) / 2
nC = math.ceil((Z95 * math.sqrt(2 * qbar * (1 - qbar))
                + ZB * math.sqrt(q1 * (1 - q1) + q2 * (1 - q2))) ** 2
               / (q1 - q2) ** 2)
print("C  Luhn vs Verhoeff miss rate: n = %d slips per arm" % nC)
print("   at 125 slips a month: %.1f months per arm" % (nC / 125))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《校验码代数与二面体群韦尔霍夫算法、订单号汇款码书号单字误抄与相邻换位检出率母典》第 8 章「实证闭环:订单台流程、订单校验位生成器与预注册检验」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-297 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026297,
  author    = {Fan, Yafu},
  title     = {The Algebra of Check Digits and Verhoeff's Dihedral-Group Code: Detection Rates for Single-Digit Slips and Adjacent Transpositions in Order, Remittance and Book Numbers},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论