All problems
Conformal Interval
Problem
Build a conformal prediction interval from calibration absolute residuals: take the k-th smallest residual with k = ceil((n + 1) * (1 - alpha)) clamped to [1, n], then return [prediction - q, prediction + q].
Empty residuals return [0.0, 0.0].
Hint
Conformal intervals carry a finite-sample coverage guarantee under exchangeability.
Test cases
case 1
in: [[1,2,3,4],0.25,10]
expected: [6,14]
case 2
in: [[1,2,3],0.5,0]
expected: [-2,2]
case 3
in: [[],0.1,5]
expected: [0,0]
Starter codePython
import math
def conformal_interval(residuals, alpha, prediction):
# Returns [lower, upper]
# Your code here
pass3 test cases · run your code against them in the editor