关于「每周抽查多少单:发现抽样与价值分层」,《四柱复式守恒代数》给出的定量结论是什么?
结论:程序取一周 400 张订单。如果错单占一成,即 40 张,要有九成把握碰到至少一张,只需抽 22 张;要有九成五把握,抽 28 张。如果错单占百分之五,即 20 张,九成五把握需要 55 张。错单占百分之二,即 8 张,需要 124 张;错单占百分之一,即 4 张,需要 211 张,已经超过总量的一半。
数据口径:本书用可运行的程序说明,单式流水本身不含任何检验:在一个示意日上漏记一笔 1,500.00 元的尾款,表格依旧自洽,只有拿银行余额来比才出现差额。 书中参数为示意;全部计算由书中程序生成;本书属于非个人化的会计、税务或法律建议。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 124, 20, 211, 22, 28, 40
| week of N | 400 orders; n = orders to re-check |
| bad rate bad orders n(90%) n(95%) binom(95%) | |
| 0.01 | 4 175 211 299 |
| 0.02 | 8 100 124 149 |
| 0.05 | 20 43 55 59 |
| 0.10 | 40 22 28 29 |
| at 2% bad and n | 124: P(miss all) = 0.0498 |
| none found in 124 -> fewer than 8 bad of 400 (95%, one-sided) | |
| N | 1600: 2% bad needs n(95%) = 142 |
| N | 6400: 2% bad needs n(95%) = 147 |
查看完整验算程序
# Chapter 6. p61: how many orders to re-check by hand each week.
# Model: discovery sampling. Invariants catch balance-moving slips,
# but an entry can be internally consistent and still wrong (a cycle
# of chapter 3, a mispriced order). To see at least one such slip with
# confidence c when E of the N orders carry it, draw n orders without
# replacement: P(miss) = C(N - E, n) / C(N, n), exact with integers.
# The binomial shortcut n = ln(1 - c) / ln(1 - p), p = E / N, is
# shown beside it. N = 400 orders a week is illustrative.
from fractions import Fraction as F
from math import comb, ceil, log
def n_exact(N, E, c):
for n in range(1, N + 1):
miss = F(comb(N - E, n), comb(N, n))
if 1 - miss >= c:
return n
return N
def n_binom(p, c):
return ceil(log(1 - c) / log(1 - p))
if __name__ == "__main__":
N = 400
print("week of N = {} orders; n = orders to re-check".format(N))
print("bad rate bad orders n(90%) n(95%) binom(95%)")
for p in (F(1, 100), F(2, 100), F(5, 100), F(10, 100)):
E = int(p * N)
print("{:7.2f} {:12d} {:8d} {:7d} {:11d}".format(
float(p), E, n_exact(N, E, F(9, 10)), n_exact(N, E, F(95, 100)),
n_binom(float(p), 0.95)))
n = n_exact(N, 8, F(95, 100))
miss = F(comb(N - 8, n), comb(N, n))
print("at 2% bad and n = {}: P(miss all) = {:.4f}".format(
n, float(miss)))
print("none found in {} -> fewer than 8 bad of {} (95%, one-sided)"
.format(n, N))
for big in (1600, 6400):
print("N = {}: 2% bad needs n(95%) = {}".format(
big, n_exact(big, big // 50, F(95, 100))))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《四柱结算与复式记账的守恒代数、代购流水零差错对账不变量母典》第 6 章「每周抽查多少单:发现抽样与价值分层」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-318 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026318,
author = {Fan, Yafu},
title = {The Conservation Algebra of Four-Pillar Settlement and Double-Entry Bookkeeping: Invariants for Error-Free Reconciliation of Buying-Agent Ledgers},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}