What does The Algebra of Check Digits conclude, in numbers, about “Closing the Loop: An Order Desk Procedure, the Order Check-Digit Generator and a Pre-Registered Test”?
Answer: Chapter 8 gives an order desk procedure, the Order Check-Digit Generator and a pre-registered test plan: the one-sided test needs 50 audited discrepancies. Marked boxes separate published evidence, runnable Python calculations (19 programs), classical sources and the author's hypotheses.
Scope of the numbers: Entry volumes, error rates and costs are illustrative; all calculations are generated by the book's programs; the book is not individual business advice. Marked boxes separate published evidence, runnable Python calculations (19 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: 50
| A | estimate share within +/- 0.03: n = 410 slips, 3.3 months |
| B | share > 0.75, exact one-sided: n = 50, reject if >= 43 |
| size 0.0453, power 0.8366 | |
| C | Luhn vs Verhoeff miss rate: n = 2423 slips per arm |
| at 125 slips a month: 19.4 months per arm |
Show the full program
# 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))Single source and citation
Fan, Y. (2026). 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 (Version 1.0.0), Chapter 8: Closing the Loop: An Order Desk Procedure, the Order Check-Digit Generator and a Pre-Registered Test. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 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}
}Other chapter answers in this book
- Chapter 1 · The Spectrum of Slips: Two Classes in Twelve Thousand Errors
- Chapter 2 · Luhn's Doubling: Why Mod 10 Misses 09 and 90
- Chapter 3 · Prime Moduli and Weights: The X of ISBN-10 and the Blind Spot of EAN-13
- Chapter 4 · The Symmetries of a Pentagon: The Dihedral Group D5 and Anti-Symmetric Permutations
- Chapter 5 · Verhoeff's Algorithm Dissected: Positions, Twins, Jumps and the Errors with No Name
- Chapter 6 · Order Numbers, Remittance References and Internal Book Numbers: A Month's Accounts
- Chapter 7 · Classics East and West: Ritual Bronzes, Red Tablets and Gauss's Congruences