关于「可交换性破裂:周末效应、增长漂移、促销冲击与三种修补」,《共形预测与订单区间》给出的定量结论是什么?
结论:第六章演示周末效应、增长漂移与促销冲击怎样破坏可交换性:合并校准时周六的覆盖率只有 0.8252,冻结的校准集在增长中漏网率升到 0.3602,按星期缩放与近期窗口可以修补。
数据口径:书中参数为示意;全部计算由书中程序生成;本书属于非个人化经营建议。 本书作蓝图修正:正态区间的缺口是本书程序的模拟结果,集中在右尾与单侧上界;东方原典句出自《元史·郭守敬传》。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.8252
| alpha = 0.05, coverage of the next day, by weekday | |||
| day | pooled | wkday/wkend | ratio score |
| Mon | 0.9955 | 0.9616 | 0.9526 |
| Tue | 0.9955 | 0.9616 | 0.9536 |
| Wed | 0.9955 | 0.9616 | 0.9526 |
| Thu | 0.9955 | 0.9616 | 0.9520 |
| Fri | 0.9861 | 0.9065 | 0.9515 |
| Sat | 0.8252 | 0.9529 | 0.9541 |
| Sun | 0.8818 | 0.9650 | 0.9541 |
| week | 0.9536 | 0.9530 | 0.9529 |
查看完整验算程序
# Chapter 6. p61: the weekend breaks exchangeability for "tomorrow".
# Model (illustrative): daily orders = 100 * f(day) * exp(e), e normal
# with sd 0.25; f = 1.0 Mon-Thu, 1.15 Fri, 1.6 Sat, 1.5 Sun. Four
# weeks fit, twelve weeks (84 days) calibrate. Pooled conformal uses
# one median centre. The weekday/weekend Mondrian version calibrates
# two groups apart (24 weekend days). The ratio score divides each
# day by its weekday median from the fit window. Coverage for each
# weekday is exact from the log-normal CDF; 2,000 repetitions.
import math
import random
import statistics
ND = statistics.NormalDist()
F = (1.0, 1.0, 1.0, 1.0, 1.15, 1.6, 1.5)
NAMES = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
S = 0.25
def cdf(d, x):
return 0.0 if x <= 0 else ND.cdf(math.log(x / (100 * F[d])) / S)
def q(sc, alpha=0.05):
k = math.ceil((len(sc) + 1) * (1 - alpha))
return math.inf if k > len(sc) else sorted(sc)[k - 1]
def rep(rng):
days = [(t % 7, 100 * F[t % 7] * math.exp(rng.gauss(0.0, S)))
for t in range(16 * 7)]
fit, cal = days[:28], days[28:]
c = statistics.median([y for _, y in fit])
qa = q([abs(y - c) for _, y in cal])
wk = [d >= 5 for d in range(7)]
cg = {g: statistics.median([y for d, y in fit if wk[d] == g])
for g in (False, True)}
qg = {g: q([abs(y - cg[g]) for d, y in cal if wk[d] == g])
for g in (False, True)}
med = [statistics.median([y for d, y in fit if d == e])
for e in range(7)]
qr = q([abs(y / med[d] - 1.0) for d, y in cal])
out = []
for d in range(7):
g = wk[d]
out.append((cdf(d, c + qa) - cdf(d, c - qa),
cdf(d, cg[g] + qg[g]) - cdf(d, cg[g] - qg[g]),
cdf(d, med[d] * (1 + qr)) - cdf(d, med[d] * (1 - qr))))
return out
if __name__ == "__main__":
rng = random.Random(20261113)
rows = [rep(rng) for _ in range(2000)]
print("alpha = 0.05, coverage of the next day, by weekday")
print("day pooled wkday/wkend ratio score")
avg = [[], [], []]
for d in range(7):
c = [math.fsum(r[d][j] for r in rows) / 2000 for j in range(3)]
for j in range(3):
avg[j].append(c[j])
print("{} {:.4f} {:.4f} {:.4f}".format(
NAMES[d], c[0], c[1], c[2]))
print("week {:.4f} {:.4f} {:.4f}".format(
*[math.fsum(a) / 7 for a in avg]))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《共形预测与无分布区间、订单量与客单价有限样本覆盖保证母典》第 6 章「可交换性破裂:周末效应、增长漂移、促销冲击与三种修补」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-306 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026306,
author = {Fan, Yafu},
title = {Conformal Prediction and Distribution-Free Intervals: Finite-Sample Coverage Guarantees for Order Counts and Order Values},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}