Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-248

Quantile Crossing Fix

Problem

Fix crossing quantile forecasts by returning [min(q_low, q_high), max(q_low, q_high)].

The lower quantile is always first in the result, restoring monotonicity.

Hint

Independent per-quantile models can cross; sorting pairs repairs it.

Test cases

case 1
in: [0.1,0.9]
expected: [0.1,0.9]
case 2
in: [0.8,0.2]
expected: [0.2,0.8]
case 3
in: [0.5,0.5]
expected: [0.5,0.5]
case 4
in: [-0.5,0.5]
expected: [-0.5,0.5]
Starter codePython
def quantile_crossing_fix(q_low, q_high):
    # Your code here
    pass

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