关于「缺陷率未知或会漂移:贝叶斯更新、样本量与检验间隔」,《三城分布式团队协同与验收》给出的定量结论是什么?
结论:缺陷率未知时,抽样买到的是信息,值得付钱的样本量有内点最优:示意参数下是 42 件,曲线在 20 到 60 件之间很平。累积数据会产生惯性,让旧的好记录压住新的警讯,所以要让旧数据退出,或者设单周报警线。缺陷率会漂移时,检验间隔也有内点最优,示意参数下是 2.32 天,并按漂移速率的平方根变化。「检验越频繁越好」在时间维度上同样不成立。
数据口径:书中的作息、午休、成本系数、汇率波动率与价格水平均为示意参数,全部计算由书中程序生成;本书是非个人化管理建议,不构成法律或税务建议,三城劳动、税务与准证事项须由当地持牌顾问确认;书中不以城市或国籍给任何人群贴标签,也不涉及任何多层分润。 书中以标注框区分已发表的证据、可运行的 Python 计算(20 段程序)、原典与作者的假说。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 20, 42, 60
| n expected h per lot | |
| 0 | 100.00 |
| 5 | 100.00 |
| 10 | 89.63 |
| 20 | 83.56 |
| 30 | 83.52 |
| 60 | 82.95 |
| 120 | 89.18 |
| best n | 42, 81.98 h; inspect-all 100.0 h; ship-all 125.0 h |
| week n d posterior mean P(p > 0.04) action | |
| 1 | 42 0 0.0161 0.083 ship rest |
| 2 | 42 1 0.0192 0.079 ship rest |
| 3 | 42 0 0.0137 0.019 ship rest |
| 4 | 42 0 0.0106 0.004 ship rest |
| 5 | 42 6 0.0348 0.301 ship rest |
| 6 | 42 4 0.0441 0.599 inspect rest |
查看完整验算程序
# Chapter 5. p51: Bayesian defect rate and the sample size worth paying for.
# Costs as in p42: k1 = 0.5 h per inspection, k2 = 12.5 h per escape, so
# the breakeven rate is 0.04; lots of N = 200. Prior on a new stream's
# defect rate p: Beta(1, 19), mean 0.05 (illustrative). Sampling n items
# and finding d defectives gives Beta(1 + d, 19 + n - d). After the
# sample the coordinator inspects the rest if the posterior mean exceeds
# 0.04 and ships it otherwise. Part one: expected cost per lot by n
# (preposterior analysis, beta-binomial predictive). Part two: a stream
# updated week by week with samples of the best n.
import math
K1, K2, N, A, B = 0.5, 12.5, 200, 1.0, 19.0
BREAK = K1 / K2
def lbeta(a, b):
return math.lgamma(a) + math.lgamma(b) - math.lgamma(a + b)
def pred(n, d, a, b):
return math.comb(n, d) * math.exp(lbeta(a + d, b + n - d) - lbeta(a, b))
def exp_cost(n, a=A, b=B):
terms = [n * K1]
for d in range(n + 1):
post = (a + d) / (a + b + n)
rest = (N - n) * min(K1, post * K2)
terms.append(pred(n, d, a, b) * rest)
return math.fsum(terms)
def tail(a, b, x0, steps=4000):
# P(p > x0) under Beta(a, b), Simpson's rule on [x0, 1]
h = (1 - x0) / steps
f = [math.exp((a - 1) * math.log(x0 + i * h)
+ (b - 1) * math.log(max(1e-300, 1 - x0 - i * h))
- lbeta(a, b)) for i in range(steps + 1)]
w = [1 if i in (0, steps) else 4 if i % 2 else 2
for i in range(steps + 1)]
return h / 3 * math.fsum(wi * fi for wi, fi in zip(w, f))
print("n expected h per lot")
for n in (0, 5, 10, 20, 30, 60, 120):
print("%-5d %10.2f" % (n, exp_cost(n)))
best = min(range(0, N), key=lambda n: (exp_cost(n), n))
print("best n = %d, %.2f h; inspect-all %.1f h; ship-all %.1f h" % (
best, exp_cost(best), N * K1, N * A / (A + B) * K2))
a, b = A, B
print("week n d posterior mean P(p > 0.04) action")
for wk, d in enumerate((0, 1, 0, 0, 6, 4), 1):
a, b = a + d, b + best - d
m = a / (a + b)
act = "inspect rest" if m > BREAK else "ship rest"
print("%4d %3d %2d %12.4f %12.3f %s" % (wk, best, d, m,
tail(a, b, BREAK), act))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《跨时区多城市分布式团队协同、异步交付核验与区域人才配置效率母典》第 5 章「缺陷率未知或会漂移:贝叶斯更新、样本量与检验间隔」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-340 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026340,
author = {Fan, Yafu},
title = {Distributed Multi-City Team Coordination, Asynchronous Deliverable Verification and Regional Talent Allocation across KL, Taipei and HCMC},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}