Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-142

Split Conformal Width

Problem

Compute the split conformal interval width: twice the quantile of absolute residuals at level alpha. Sort the absolute residuals and take index ceil((1 - alpha) * n) - 1, clamped to [0, n-1]; return 2 * that score.

Return 0.0 for empty residuals.

Hint

The quantile index uses ceil so the interval covers at least the requested share.

Test cases

case 1
in: [[1,-2,3],0.5]
expected: 4
case 2
in: [[0.1,-0.2,0.3,0.4],0.75]
expected: 0.2
case 3
in: [[1,2,3,4,5],0.8]
expected: 2
case 4
in: [[-1,1],1]
expected: 2
Starter codePython
import math
def split_conformal_width(residuals, alpha):
    # Your code here
    pass

4 test cases · run your code against them in the editor