关于「每周看一次:成组序贯设计与 α 消耗函数」,《A/B 测试的偷看与小流量》给出的定量结论是什么?
结论:第五章给出成组序贯门槛,五次查看时 Pocock 为 2.4133、O'Brien-Fleming 最后一次为 2.0402。
数据口径:书中的站点、流量、转化率与提升幅度均为示意参数;全部计算由书中程序生成;本书不是个人化的经营、法律或理财建议。 书中以标注框区分已发表的证据、可运行的 Python 计算(19 段程序)、原典与作者的假说。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 2.0402, 2.4133
| two-sided alpha 0.05 with K equally spaced looks | |||||
| K | Pocock c | p per look | OBF C | first-look p | last-look p |
| 1 | 1.9600 | 0.0500 | 1.9600 | 5.00e-02 | 0.0500 |
| 2 | 2.1783 | 0.0294 | 1.9775 | 5.16e-03 | 0.0480 |
| 3 | 2.2896 | 0.0220 | 2.0042 | 5.18e-04 | 0.0451 |
| 4 | 2.3614 | 0.0182 | 2.0245 | 5.15e-05 | 0.0429 |
| 5 | 2.4133 | 0.0158 | 2.0402 | 5.06e-06 | 0.0413 |
| 10 | 2.5552 | 0.0106 | 2.0867 | 4.15e-11 | 0.0369 |
查看完整验算程序
# Chapter 5. p51: Pocock and O'Brien-Fleming bars that keep alpha at 0.05
# Model: K equally spaced looks at accumulating normal data, two-sided.
# Pocock (1977): the same bar c at every look. O'Brien and Fleming
# (1979): bar C * sqrt(K / k) at look k, very strict early. Both
# constants are found by bisection so that the exact crossing
# probability under H0 (p11's grid recursion) equals 0.05.
import math
from statistics import NormalDist
N01 = NormalDist()
H = 0.05 # grid width in standard deviations
WIDTH = 7.0 # kernel cut at 7 sd
def cross_curve(bounds, h=H):
"""Cumulative P(|S_k| >= b_k*sqrt(k) at some look <= k)."""
cdf = N01.cdf
m = int(WIDTH / h) + 1
kern = [cdf((d + .5) * h) - cdf((d - .5) * h)
for d in range(-m, m + 1)]
mass, n0 = [1.0], 0
out = []
for k, b in enumerate(bounds, 1):
lim = b * math.sqrt(k)
n = int(lim / h + 0.5)
new = []
for i in range(-n, n + 1):
lo = max((i - .5) * h, -lim)
hi = min((i + .5) * h, lim)
if hi <= lo:
new.append(0.0)
continue
full = lo == (i - .5) * h and hi == (i + .5) * h
acc = []
for jj, w in enumerate(mass):
d = i - (jj - n0)
if w == 0.0 or d < -m or d > m:
continue
if full:
acc.append(w * kern[d + m])
else:
u = (jj - n0) * h
acc.append(w * (cdf(hi - u) - cdf(lo - u)))
new.append(math.fsum(acc))
mass, n0 = new, n
out.append(1.0 - math.fsum(mass))
return out
def bisect(f, lo, hi, target=0.05, it=28):
for _ in range(it):
mid = (lo + hi) / 2
if f(mid) > target:
lo = mid
else:
hi = mid
return (lo + hi) / 2
def main():
print("two-sided alpha 0.05 with K equally spaced looks")
print(" K Pocock c p per look OBF C first-look p last-look p")
for k in (1, 2, 3, 4, 5, 10):
c = bisect(lambda x: cross_curve([x] * k)[-1], 1.5, 3.5)
obf = bisect(lambda x: cross_curve(
[x * math.sqrt(k / j) for j in range(1, k + 1)])[-1],
1.5, 3.5)
pp = 2 * (1 - N01.cdf(c))
p1 = 2 * (1 - N01.cdf(obf * math.sqrt(k)))
pk = 2 * (1 - N01.cdf(obf))
print("{:2d} {:8.4f} {:10.4f} {:6.4f} {:12.2e} {:11.4f}".format(
k, c, pp, obf, p1, pk))
main()唯一数据源与引用
范雅福(Fan, Y.). (2026). 《A/B测试偷看早停假阳性膨胀、序贯概率比检验与小流量站点最小样本母典》第 5 章「每周看一次:成组序贯设计与 α 消耗函数」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-217 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026217,
author = {Fan, Yafu},
title = {Peeking-Inflated False Positives in A/B Tests, Sequential Probability Ratio Tests and Minimum Samples for Low-Traffic Sites},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}