Skip to content
DeepForgeby svx
All problems

C51 Support Spacing

Problem

Build the fixed support of a C51 categorical value distribution.

With n_atoms atoms spanning [v_min, v_max], the spacing is dz = (v_max - v_min) / (n_atoms - 1) and support[i] = v_min + i * dz. A single atom gives [v_min] and a non-positive atom count gives [].

Hint

The support is a uniform grid, so every Bellman target is projected back onto it.

Test cases

case 1
in: [0,3,4]
expected: [0,1,2,3]
case 2
in: [-1,1,5]
expected: [-1,-0.5,0,0.5,1]
case 3
in: [2,2,3]
expected: [2,2,2]
case 4
in: [0,1,1]
expected: [0]
case 5
in: [0,1,0]
expected: []
Starter codePython
def c51_support_spacing(v_min, v_max, n_atoms):
    # Your code here
    pass

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