== Listing 2.1: the coverage guarantee, simulated ==
n=100, alpha=0.1, repetitions=4000
theory bounds: [0.9000, 0.9099]
mean coverage over calibration sets: 0.9003  (exact mean (n+1-l)/(n+1) = 0.9010)
std of coverage over calibration sets: 0.0308  (Beta std = 0.0296)
share of calibration sets with coverage < 1-alpha: 0.453

== Listing 2.2: split conformal on the diabetes data ==
n_cal=150, n_test=142, alpha=0.1, repetitions=200
linear  coverage 0.898  mean width  185.8
forest  coverage 0.897  mean width  191.6

== Listing 2.3: split conformal versus CQR, heteroscedastic noise ==
method         coverage   width   coverage by |x| bin [0,1)  [1,2)  [2,3)
split (abs)       0.908    2.85   0.999       0.949       0.775
CQR               0.898    2.28   0.935       0.886       0.873

== Listing 2.4: group-conditional coverage with Mondrian conformal ==
group   share  split cov  Mondrian cov  split width  Mondrian width
0        0.60      0.997         0.891         2.98            1.62
1        0.30      0.870         0.913         2.98            3.38
2        0.10      0.455         0.936         2.98            9.20
overall coverage: split 0.904, Mondrian 0.902

== Listing 2.5: covariate shift and weighted conformal ==
target coverage 0.90; calibration data ~ N(0,1), test data ~ N(1.5,1)
effective sample size of the weights: 391 of 3000
unweighted split   coverage 0.729  median width 1.60  share of infinite intervals 0.000
weighted (true w)  coverage 0.909  median width 2.85  share of infinite intervals 0.001
weighted (est. w)  coverage 0.905  median width 2.80  share of infinite intervals 0.000

== Listing 2.6: conformal risk control for a multi-label task ==
alpha=0.1, n_cal=500, repetitions=2000, labels per item=20
mean false-negative rate on fresh data: 0.0963  (target <= 0.1)
share of calibration sets with risk above alpha: 0.358
mean set size: 3.94 of 20 labels
