All problems
Reward Z-Score Normalization
Problem
Normalize a group of rewards by z-score: (r - mean) / std using the population standard deviation. If the standard deviation is 0, return zeros.
The signature is reward_normalization(rewards).
Hint
Group-relative normalization is what makes GRPO advantages scale-free.
Test cases
case 1
in: [[1,3]]
expected: [-1,1]
case 2
in: [[5,5]]
expected: [0,0]
case 3
in: [[1,2,3]]
expected: [-1.2247448714,0,1.2247448714]
case 4
in: [[0,10,20]]
expected: [-1.2247448714,0,1.2247448714]
Starter codePython
import math
def reward_normalization(rewards):
# Your code here
pass4 test cases · run your code against them in the editor