关于「精确递推:样本量的长尾与截断的代价」,《规则的一生》给出的定量结论是什么?

结论:精确递推给出了 Wald 公式之外的三件事。第一,真实错误率是 0.0470 与 0.2000,都在上界 0.0625 与 0.2105 之内。第二,平均样本量在两个设计点上是固定样本的 0.464 与 0.632,平庸规则那里升到 0.748,而且有接近四分之一的平庸规则会比固定样本跑得更久。第三,截断有代价:到期一律淘汰,9 周上限的功效只有 0.6548;到期按符号判,第一类错误率升到 0.0876。这些都假定每来一个访客就看一次,基线也确切已知。可是每周雷达是一周看一次,基线也要从对照组估计。批次与基线来源,会把这些数字推向哪边?第四章把检验接进真实的转化流。

数据口径:书中的转化率、流量与每周计数均为示意;全部计算由书中程序生成;本书属非个人化经营方法,不构成经营、法律或投资建议,规则的转正、降级与退役须由主事者人工放行,紧迫感只能来自真实库存与真实截止。 书中以标注框区分已发表的证据、可运行的 Python 计算(20 段程序)、原典与作者的假说。

English version

对照数据表

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

exact SPRT, p0 0.030 vs p1 0.036, alpha 0.05, beta 0.20
truth P(KEEP) P(CUT) open@60k E[N] Wald E[N] median p90
p00.0470 0.9530 5.8e-12 2468 2444 1740 5265
p10.8000 0.2000 1.0e-11 3360 3275 2713 6538
p0: E[N]/fixed n 0.464 P(N > fixed n 5314)0.0977
p1: E[N]/fixed n 0.632 P(N > fixed n 5314)0.1692
Wald bounds: alpha' <0.0625, beta' <= 0.2105; exact: 0.0470, 0.2000
查看完整验算程序
# Chapter 3. p31: exact OC and ASN of the Bernoulli SPRT, visitor by visitor
# Model: SPRT of p0 0.03 against p1 0.036 with alpha 0.05, beta 0.20
# (illustrative p0 and lift, charter error rates). Because the log
# ratio after n visitors depends only on the conversion count k, the
# set of open paths is a short list of k values; we push their exact
# probabilities forward one visitor at a time and record the mass that
# leaves through KEEP or CUT. E[N] is the sum of survival probabilities
# P(N > n). Run to 60,000 visitors; the mass still open is printed.
import math

P0, P1 = 0.03, 0.036
ALPHA, BETA = 0.05, 0.20
A = math.log((1 - BETA) / ALPHA)
B = math.log(BETA / (1 - ALPHA))
LA = math.log(P1 / P0)
LB = math.log((1 - P1) / (1 - P0))
N_MAX = 60000
N_FIX = 5314                    # fixed-sample n from p22


def exact(p, n_max=N_MAX):
    open_k = {0: 1.0}
    keep, cut, surv = [], [], [1.0]
    for n in range(1, n_max + 1):
        nxt = {}
        for k, m in open_k.items():
            nxt[k] = nxt.get(k, 0.0) + m * (1 - p)
            nxt[k + 1] = nxt.get(k + 1, 0.0) + m * p
        open_k = {}
        for k in sorted(nxt):
            llr = k * LA + (n - k) * LB
            if llr >= A:
                keep.append(nxt[k])
            elif llr <= B:
                cut.append(nxt[k])
            else:
                open_k[k] = nxt[k]
        surv.append(math.fsum(open_k.values()))
    return math.fsum(keep), math.fsum(cut), surv


def quantile(surv, q):
    for n, s in enumerate(surv):
        if 1 - s >= q:
            return n
    return None


def wald(p):
    ez = math.fsum([p * LA, (1 - p) * LB])
    oc = 1 - ALPHA if p == P0 else BETA
    return math.fsum([oc * B, (1 - oc) * A]) / ez


print("exact SPRT, p0 %.3f vs p1 %.3f, alpha %.2f, beta %.2f"
      % (P0, P1, ALPHA, BETA))
print("truth  P(KEEP)  P(CUT)  open@60k   E[N]  Wald E[N]  median"
      "  p90")
rows = {}
for lab, p in (("p0", P0), ("p1", P1)):
    kp, cp, surv = exact(p)
    en = math.fsum(surv[:-1])
    rows[lab] = (kp, cp, surv, en)
    print("%-5s  %7.4f  %6.4f  %8.1e  %5.0f  %9.0f  %6d  %5d"
          % (lab, kp, cp, surv[-1], en, wald(p), quantile(surv, 0.5),
             quantile(surv, 0.9)))
for lab in ("p0", "p1"):
    kp, cp, surv, en = rows[lab]
    print("%s: E[N]/fixed n %.3f   P(N > fixed n %d) = %.4f"
          % (lab, en / N_FIX, N_FIX, surv[N_FIX]))
print("Wald bounds: alpha' <= %.4f, beta' <= %.4f; exact: %.4f, %.4f"
      % (ALPHA / (1 - BETA), BETA / (1 - ALPHA), rows["p0"][0],
         rows["p1"][1]))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《线上规则实证淘汰、序贯概率比检验接入真实转化流与新文案规则转正降级母典》第 3 章「精确递推:样本量的长尾与截断的代价」(版本 1.0.0). 5D Library. DOI 待发布

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

BibTeX
@book{fan2026263,
  author    = {Fan, Yafu},
  title     = {Empirical Retirement of Live Rules: Wiring the Sequential Probability Ratio Test into Real Conversion Streams to Promote, Demote and Retire Copy Rules},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论