All problems
Streaming Reward Normalization
Problem
Normalize a list of rewards by their own mean and population standard deviation: (r - mean) / (std + epsilon). If the standard deviation is zero return zeros, and an empty list returns [].
Hint
Reward normalization keeps the advantage scale stable as training progresses.
Test cases
case 1
in: [[1,2,3],0]
expected: [-1.224744871391589,0,1.224744871391589]
case 2
in: [[5],0]
expected: [0]
case 3
in: [[],0]
expected: []
case 4
in: [[2,2,2],1e-8]
expected: [0,0,0]
Starter codePython
import math
def streaming_reward_normalize(rewards, epsilon):
# Your code here
pass4 test cases · run your code against them in the editor