关于「阈值漂移:折扣贝塔、滑动窗口与累积和报警」,《条件参数化规则蒸馏与在线校准》给出的定量结论是什么?
结论:第五章比较折扣、滑动窗口与累积和报警,滑动窗口在台阶变化下合计遗憾 33.0。
数据口径:书中参数为示意,全部计算由书中程序生成。 本书是非个人化经营分析,不构成投资、法律或医疗意见,不对应任何真实客户或成交。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 33.0
| sessions 12,000, change at 5,000, runs 30 | ||||
| policy | regret before | regret after | total | p90 total |
| fixed | 0.0 | 84.0 | 84.0 | 84.0 |
| stationary | 10.1 | 60.7 | 70.8 | 85.4 |
| discount | 21.2 | 29.0 | 50.2 | 57.9 |
| window | 11.2 | 21.8 | 33.0 | 49.4 |
| effective memory of the discount 0.998: 500 sessions |
查看完整验算程序
# Chapter 5. p51: thresholds drift when traffic changes. Two copy tiers;
# at session 5,000 of 12,000 the traffic mix changes and their true pay
# rates swap order: tier 0 goes 0.045 -> 0.030, tier 1 goes
# 0.032 -> 0.042 (illustrative). 30 runs per policy:
# fixed : tier 0 forever (the threshold set before the change)
# stationary: Thompson sampling with all history weighted equally
# discount : Thompson with counts multiplied by 0.998 each session
# window : Thompson on the last 1,500 sessions of each tier only
# Regret is measured against the best tier of each period.
import collections
import math
import random
T, CHANGE, RUNS = 12000, 5000, 30
BEFORE, AFTER = (0.045, 0.032), (0.030, 0.042)
def run(policy, rng):
a = [0.0, 0.0]
b = [0.0, 0.0]
hist = [collections.deque(), collections.deque()]
lost_pre, lost_post = [], []
for t in range(T):
p = BEFORE if t < CHANGE else AFTER
if policy == "fixed":
arm = 0
else:
draws = [rng.betavariate(1.0 + a[i], 1.0 + b[i])
for i in range(2)]
arm = 0 if draws[0] >= draws[1] else 1
r = 1 if rng.random() < p[arm] else 0
if policy == "discount":
for i in range(2):
a[i] *= 0.998
b[i] *= 0.998
a[arm] += r
b[arm] += 1 - r
if policy == "window":
hist[arm].append(r)
if len(hist[arm]) > 1500:
old = hist[arm].popleft()
a[arm] -= old
b[arm] -= 1 - old
gap = max(p) - p[arm]
(lost_pre if t < CHANGE else lost_post).append(gap)
return math.fsum(lost_pre), math.fsum(lost_post)
def main():
seeds = {"fixed": random.Random(5101),
"stationary": random.Random(5102),
"discount": random.Random(5103),
"window": random.Random(5104)}
print("sessions {:,}, change at {:,}, runs {}".format(T, CHANGE, RUNS))
print(" policy regret before regret after total p90 total")
for pol in ("fixed", "stationary", "discount", "window"):
pre, post, tot = [], [], []
for _ in range(RUNS):
x, y = run(pol, seeds[pol])
pre.append(x)
post.append(y)
tot.append(x + y)
tot.sort()
print(" {:<11} {:>10.1f} {:>10.1f} {:>6.1f} {:>6.1f}".format(
pol, math.fsum(pre) / RUNS, math.fsum(post) / RUNS,
math.fsum(tot) / RUNS, tot[26]))
print("effective memory of the discount 0.998: {:.0f} sessions".format(
1.0 / (1.0 - 0.998)))
if __name__ == "__main__":
main()唯一数据源与引用
范雅福(Fan, Y.). (2026). 《高阶知识蒸馏进化、条件参数化编译与实盘转化反馈校准母典》第 5 章「阈值漂移:折扣贝塔、滑动窗口与累积和报警」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-377 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026377,
author = {Fan, Yafu},
title = {Next-Generation Knowledge Distillation, Context-Parametric Compilation and Live-Conversion Feedback Calibration},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}