src/conformal_tubes/core.pylines 29–30, 37–41, 60–68 · commit 356046a
29 def halfwidth(self, kappa: float) -> Array:
30 return self.a + kappa * self.b
⋮
37 def scores(self, y: Array) -> Array:
38 """y (N,P,o): smallest kappa with y inside the interval hull of the tube at every step."""
39 d = np.abs(y - self.centre)
40 s = np.where(self.b > FLOOR, (d - self.a) / np.maximum(self.b, FLOOR), np.where(d <= self.a + 1e-12, -np.inf, np.inf))score
41 return np.maximum(s.max(axis=(1, 2)), 0.0)
⋮
60def kappa_hat(scores: Array, eps: float) -> float:
61 """ceil((N+1)(1-eps))-th smallest calibration score (inf if the index exceeds N): Theorem 1."""
62 s, n = np.sort(scores), len(scores)
63 j = math.ceil((n + 1) * (1 - eps))quantile index
⋮ 4 lines: too few scores for this ε, so the tube is unbounded
68 return float(s[j - 1])κ̂