[Question] Why does VecNormalize normalize rewards by returns instead of rewards?

Author: pstahlhofenCreated Aug 25, 2026Updated Aug 25, 2026
Labelsduplicatequestion

❓ Question

I just read the code of VecNormalize and was surprised by the way the reward normalization is computed. I had assumed the wrapper to keep track of past rewards, storing their running mean and variance. New rewards would then be normalized using this statistic. Instead the wrapper appears to normalize the rewards using statistics of the returns, i.e. the discounted sums over rewards. This is done in the _update_reward function. For environments with only positive rewards (like CartPole) the value of the return increases as the episode progresses, particularly for large values of gamma, while the value of the reward does not depend on the time step within the episode. Normalizing rewards by statistics over returns seems counterintuitive to me, so I wanted to ask if this is a bug or intended behaviour

Checklist

Source: DLR-RM/stable-baselines3