== Listing 0.1: proper and improper scores ==
Brier           best report 0.30 (truth q=0.3), expected score at best 0.2100, at q 0.2100
log loss        best report 0.30 (truth q=0.3), expected score at best 0.6109, at q 0.6109
absolute error  best report 0.01 (truth q=0.3), expected score at best 0.3040, at q 0.4200
Brier closed form q(1-q)+(p-q)^2 at p=0.6, q=0.3: 0.3000; direct: 0.3000
forecaster          Brier   log loss
true probability    0.1775  0.5291
overconfident model 0.2005  0.6779
base rate only      0.2500  0.6931

== Listing 0.2: reliability table, ECE and the Brier decomposition ==
bin  count  mean forecast  observed freq
  0   4929          0.029          0.146
  1   1524          0.146          0.289
  2   1071          0.249          0.361
  3    872          0.348          0.398
  4    838          0.449          0.444
  5    856          0.552          0.484
  6    920          0.650          0.514
  7   1126          0.751          0.545
  8   1611          0.853          0.657
  9   6253          0.973          0.824
ECE (10 bins): 0.1315
Brier decomposition: rel 0.0192  res 0.0708  unc 0.2500  within -0.0016
rel - res + unc + within = 0.1969;  Brier = 0.1969
noise floor: ECE of the TRUE probabilities (perfectly calibrated), 10 bins
  n=   200: mean ECE 0.0735
  n=  2000: mean ECE 0.0223
  n= 20000: mean ECE 0.0076

== Listing 0.3: isotonic recalibration on held-out data ==
test set 20000, repetitions 40; mean over repetitions with 95% CI half-width
n_cal   method        ECE              Brier            log loss
  300   raw         0.1313 +- 0.0000   0.1954 +- 0.0000   0.6624 +- 0.0000
  300   isotonic    0.0437 +- 0.0037   0.1795 +- 0.0005   0.5714 +- 0.0114
 3000   raw         0.1313 +- 0.0000   0.1954 +- 0.0000   0.6624 +- 0.0000
 3000   isotonic    0.0182 +- 0.0015   0.1757 +- 0.0001   0.5287 +- 0.0011

== Listing 0.4: split conformal coverage is Beta distributed ==
n=50, alpha=0.1, k=46, repetitions=4000
theory bounds on mean coverage: [0.9000, 0.9196]
mean coverage 0.9009 (Beta mean 0.9020)
std of coverage 0.0437 (Beta std 0.0412)
share of calibration sets below 1-alpha: 0.426 (Beta: 0.431)
corrected quantile is infinite for n < 9: n=8 -> inf, n=9 -> 8.0

== Listing 0.5: conformal classification sets on digits ==
n_train=500, n_cal=500, n_test=797, alpha=0.1, repetitions=20
classifier accuracy 0.937
coverage 0.897 +- 0.008
mean set size 0.929; share singletons 0.922; share empty sets 0.075
per-class coverage: 0.98 0.86 0.94 0.85 0.94 0.93 0.95 0.95 0.73 0.85
lowest per-class coverage 0.728 (class 8), highest 0.981

== Listing 0.6: off-policy estimators with correct propensities ==
actions K=4, context dimension 3, n=2000 logged rounds, repetitions=200
true value of logging policy 0.3351; of target policy (beta=2.0) 0.5661
ips       mean 0.5691  bias +0.0030 (+-0.0072)  std 0.0523  RMSE 0.0522
snips     mean 0.5686  bias +0.0026 (+-0.0040)  std 0.0290  RMSE 0.0290
dm_good   mean 0.5671  bias +0.0010 (+-0.0026)  std 0.0189  RMSE 0.0188
dr_good   mean 0.5680  bias +0.0019 (+-0.0035)  std 0.0250  RMSE 0.0250
dr_bad    mean 0.5684  bias +0.0023 (+-0.0051)  std 0.0365  RMSE 0.0365
effective sample size of the weights: mean 332 of 2000; largest weight seen 511.6

== Listing 0.7: double robustness, 2 x 2 design ==
target value 0.5661; reported propensity is proportional to mu^0.4 in the second block
-- propensities correct --
ips       mean 0.5654  bias -0.0007 (+-0.0059)  std 0.0426  RMSE 0.0425
dr_good   mean 0.5648  bias -0.0012 (+-0.0034)  std 0.0244  RMSE 0.0244
dr_bad    mean 0.5645  bias -0.0015 (+-0.0043)  std 0.0307  RMSE 0.0306
-- propensities wrong --
ips       mean 0.4079  bias -0.1581 (+-0.0032)  std 0.0228  RMSE 0.1597
dr_good   mean 0.5651  bias -0.0010 (+-0.0027)  std 0.0195  RMSE 0.0194
dr_bad    mean 0.4884  bias -0.0777 (+-0.0026)  std 0.0185  RMSE 0.0798
direct method (propensities not used): good model bias -0.0009, constant model bias -0.2400

== Listing 0.8: overlap, effective sample size and clipping ==
n=2000, repetitions=100; target policy sharpness beta (logging policy fixed)
beta  true V  ESS    IPS rmse  SNIPS rmse  clip10 bias  clip10 rmse  DR rmse
 0.5  0.4789    760  0.0239    0.0174      -0.0130      0.0242       0.0167
 1.0  0.5264    503  0.0310    0.0207      -0.0194      0.0313       0.0181
 2.0  0.5661    339  0.0478    0.0297      -0.0378      0.0514       0.0242
 4.0  0.5860    270  0.0444    0.0291      -0.0497      0.0585       0.0250
 8.0  0.5926    246  0.0473    0.0287      -0.0497      0.0607       0.0233
