Skip to content
DeepForgeby svx
All problems

Advantage Normalization

Problem

Normalize a batch of advantages by its maximum absolute deviation.

Subtract the mean and divide by the largest |a - mean|. If every centered advantage is zero return zeros; an empty batch returns [].

Hint

Centering plus max-abs scaling bounds every normalized advantage in [-1, 1].

Test cases

case 1
in: [[1,2,3]]
expected: [-1,0,1]
case 2
in: [[0,0,0]]
expected: [0,0,0]
case 3
in: [[]]
expected: []
case 4
in: [[-2,2]]
expected: [-1,1]
Starter codePython
def normalize_advantages_max(advantages):
    # Your code here
    pass

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