关于「边际不是条件:流量分档、客群分层与宽到没用的区间」,《共形预测与订单区间》给出的定量结论是什么?

结论:第五章区分边际与条件覆盖,高流量日的覆盖率可跌到 0.8798,按流量缩放的得分把三档都拉回 0.95 附近。

数据口径:书中参数为示意;全部计算由书中程序生成;本书属于非个人化经营建议。 本书作蓝图修正:正态区间的缺口是本书程序的模拟结果,集中在右尾与单侧上界;东方原典句出自《元史·郭守敬传》。

English version

对照数据表

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

alpha = 0.05, m = 200; coverage by traffic band
scoreallV<800800-1400V>=1400mean width
plain |r|0.95250.99980.97790.879821.68
|r| / V0.95110.94830.95330.951617.75
查看完整验算程序
# Chapter 5. p51: marginal coverage hides unequal days.
# Model (illustrative): daily visitors V uniform on 200 to 2,000;
# orders Y = 0.03 V + noise with sd 0.004 V (noise grows with
# traffic). A least-squares line is fitted on 200 days, 200 days
# calibrate, and 6,000 new days test; 40 repetitions. Score A is the
# plain residual |y - yhat|; score B divides it by V (a locally
# weighted score in the spirit of Lei et al. 2018). Coverage is
# reported by traffic band.
import math
import random
import statistics


def day(rng):
    v = rng.uniform(200.0, 2000.0)
    return v, 0.03 * v + rng.gauss(0.0, 0.004 * v)


def fit(rows):
    vs = [r[0] for r in rows]
    ys = [r[1] for r in rows]
    mv, my = statistics.fmean(vs), statistics.fmean(ys)
    sxy = math.fsum((v - mv) * (y - my) for v, y in rows)
    sxx = math.fsum((v - mv) ** 2 for v in vs)
    b = sxy / sxx
    return my - b * mv, b


def band(v):
    return 0 if v < 800 else (1 if v < 1400 else 2)


if __name__ == "__main__":
    rng = random.Random(20261113)
    hits = {s: [[0, 0], [0, 0], [0, 0]] for s in "AB"}
    wid = {"A": [], "B": []}
    for _ in range(40):
        a, b = fit([day(rng) for _ in range(200)])
        cal = [day(rng) for _ in range(200)]
        k = math.ceil(201 * 0.95)
        qa = sorted(abs(y - a - b * v) for v, y in cal)[k - 1]
        qb = sorted(abs(y - a - b * v) / v for v, y in cal)[k - 1]
        for _ in range(6000):
            v, y = day(rng)
            r = abs(y - a - b * v)
            g = band(v)
            for s, h in (("A", qa), ("B", qb * v)):
                hits[s][g][0] += (r <= h)
                hits[s][g][1] += 1
                wid[s].append(2 * h)
    print("alpha = 0.05, m = 200; coverage by traffic band")
    print("score         all     V<800   800-1400  V>=1400  mean width")
    for s, lab in (("A", "plain |r|"), ("B", "|r| / V")):
        t = hits[s]
        tot = (t[0][0] + t[1][0] + t[2][0]) / (t[0][1] + t[1][1] + t[2][1])
        print("{:<12s}  {:.4f}  {:.4f}  {:.4f}    {:.4f}   {:.2f}".format(
            lab, tot, t[0][0] / t[0][1], t[1][0] / t[1][1],
            t[2][0] / t[2][1], statistics.fmean(wid[s])))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《共形预测与无分布区间、订单量与客单价有限样本覆盖保证母典》第 5 章「边际不是条件:流量分档、客群分层与宽到没用的区间」(版本 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}
}

本书其他章节结论