All problems
QR-DQN Quantile Midpoint Bin
Problem
Map a probability level p to the index of the quantile midpoint bin it falls in.
Split [0, 1] into n_quantiles equal bins and return floor(p * n_quantiles), clamped so p <= 0 gives 0 and p >= 1 gives n_quantiles - 1. A non-positive quantile count returns -1.
Hint
The bin index tells you which quantile head should receive the sampled tau.
Test cases
case 1
in: [0.3,4]
expected: 1
case 2
in: [0.75,4]
expected: 3
case 3
in: [0.999,4]
expected: 3
case 4
in: [0,5]
expected: 0
case 5
in: [1,5]
expected: 4
Starter codePython
def qr_midpoint_bin(p, n_quantiles):
# Your code here
pass5 test cases · run your code against them in the editor