关于「汤普森采样与后悔:从 1933 年的两份小样本到对照均分」,《夜间自治漏斗》给出的定量结论是什么?
结论:第二章比较平均分、先试后定、UCB1 与汤普森采样;
数据口径:书中参数为示意;全部计算由书中 23 段程序生成;本书是非个人化的经营分析,不构成经营、法律或财务建议,不宣称任何转化率提升的保证。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库
| rule | mean regret | P10 | P90 | share to best |
| equal | 60.0 | 60.0 | 60.0 | 0.333 |
| etc | 33.0 | 24.0 | 59.9 | 0.603 |
| ucb1 | 53.6 | 50.1 | 57.6 | 0.387 |
| ts | 30.1 | 13.0 | 54.1 | 0.615 |
| visitors 10,000; best variant pays 0.052 |
查看完整验算程序
# Chapter 2. p21: cumulative regret of four allocation rules.
# Three page variants with illustrative pay rates. Regret is expected
# conversions lost against always showing the best variant:
# sum over visitors of (p_best - p_shown). Rules: equal split for the
# whole horizon (classic A/B), explore-then-commit (equal split for the
# first 40 percent, then the leader), UCB1 (Auer et al. 2002) and
# Thompson sampling with Beta(1, 1) priors (Thompson 1933).
import math
import random
P = [0.040, 0.046, 0.052]
T = 10000
REPS = 100
rng = random.Random(40521)
BEST = max(P)
def run(rule):
s = [0] * 3
n = [0] * 3
reg = []
for t in range(T):
if rule == "equal":
a = t % 3
elif rule == "etc":
if t < 0.4 * T:
a = t % 3
else:
a = max(range(3), key=lambda k: s[k] / n[k])
elif rule == "ucb1":
if t < 3:
a = t
else:
a = max(range(3), key=lambda k: s[k] / n[k]
+ math.sqrt(2 * math.log(t) / n[k]))
else:
a = max(range(3), key=lambda k: rng.betavariate(
1 + s[k], 1 + n[k] - s[k]))
y = 1 if rng.random() < P[a] else 0
s[a] += y
n[a] += 1
reg.append(BEST - P[a])
return math.fsum(reg), n[2] / T
print("rule mean regret P10 P90 share to best")
for rule in ["equal", "etc", "ucb1", "ts"]:
regs, shares = [], []
for _ in range(REPS):
r, sh = run(rule)
regs.append(r)
shares.append(sh)
regs.sort()
print("{:<8} {:>10.1f} {:>7.1f} {:>6.1f} {:.3f}".format(
rule, math.fsum(regs) / REPS, regs[REPS // 10],
regs[9 * REPS // 10], math.fsum(shares) / REPS))
print("visitors {:,}; best variant pays {:.3f}".format(T, BEST))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《夜间自治漏斗微创调优、多臂赌博机流量自动倾斜与零人工转化率自举母典》第 2 章「汤普森采样与后悔:从 1933 年的两份小样本到对照均分」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-405 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026405,
author = {Fan, Yafu},
title = {Autonomous Nightly Funnel Micro-Surgery, Bandit Traffic Allocation and Zero-Touch Conversion Self-Improvement},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}