关于「正确的名次:为什么要「加一」,以及有限样本覆盖保证从哪里来」,《共形预测与订单区间》给出的定量结论是什么?
结论:第二章证明名次必须是校准集大小加一后乘以一减 α 再向上取整,少加一时二十个校准值的覆盖率只有 0.9048。
数据口径:书中参数为示意;全部计算由书中程序生成;本书属于非个人化经营建议。 本书作蓝图修正:正态区间的缺口是本书程序的模拟结果,集中在右尾与单侧上界;东方原典句出自《元史·郭守敬传》。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.9048
| alpha = 0.05; exact coverage = k / (m + 1) | |||||
| m | k | level k/m | coverage | bound 1-a+1/(m+1) | naive cov |
| 10 | 11 | infinite interval (k > m) | |||
| 19 | 19 | 1.0000 | 0.9500 | 1.0000 | 0.9500 |
| 20 | 20 | 1.0000 | 0.9524 | 0.9976 | 0.9048 |
| 30 | 30 | 1.0000 | 0.9677 | 0.9823 | 0.9355 |
| 39 | 38 | 0.9744 | 0.9500 | 0.9750 | 0.9500 |
| 50 | 49 | 0.9800 | 0.9608 | 0.9696 | 0.9412 |
| 99 | 95 | 0.9596 | 0.9500 | 0.9600 | 0.9500 |
| 100 | 96 | 0.9600 | 0.9505 | 0.9599 | 0.9406 |
| 199 | 190 | 0.9548 | 0.9500 | 0.9550 | 0.9500 |
| 999 | 950 | 0.9510 | 0.9500 | 0.9510 | 0.9500 |
| smallest m with a finite interval: 19 | |||||
| for alpha = 0.10: 9; for alpha = 0.01: 99 |
查看完整验算程序
# Chapter 2. p21: the correct rank k = ceil((m + 1)(1 - alpha)).
# Model: m exchangeable calibration scores with no ties. The new
# score is equally likely to fall in any of the m + 1 gaps, so the
# interval built from the k-th smallest score covers with probability
# exactly k / (m + 1), computed here as a Fraction. The naive rank
# ceil(m (1 - alpha)) ignores the new point and can fall short.
import math
from fractions import Fraction
def rank(m, alpha):
return math.ceil((m + 1) * (1 - alpha))
if __name__ == "__main__":
alpha = Fraction(5, 100)
print("alpha = 0.05; exact coverage = k / (m + 1)")
print(" m k level k/m coverage bound 1-a+1/(m+1) naive cov")
for m in (10, 19, 20, 30, 39, 50, 99, 100, 199, 999):
k = rank(m, alpha)
k0 = math.ceil(m * (1 - alpha))
if k > m:
print("{:4d} {:3d} infinite interval (k > m)".format(m, k))
continue
cov = Fraction(k, m + 1)
top = 1 - alpha + Fraction(1, m + 1)
print("{:4d} {:3d} {:.4f} {:.4f} {:.4f} {:.4f}"
.format(m, k, k / m, float(cov), float(top),
k0 / (m + 1)))
print("smallest m with a finite interval: {}".format(
min(m for m in range(1, 200) if rank(m, alpha) <= m)))
print("for alpha = 0.10: {}; for alpha = 0.01: {}".format(
min(m for m in range(1, 999) if rank(m, Fraction(1, 10)) <= m),
min(m for m in range(1, 999) if rank(m, Fraction(1, 100)) <= m)))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《共形预测与无分布区间、订单量与客单价有限样本覆盖保证母典》第 2 章「正确的名次:为什么要「加一」,以及有限样本覆盖保证从哪里来」(版本 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}
}