# How to scale all positive continuous reward?

My RL project has all positive continuous rewards for every step and the goal is to have the maximum cumulative reward (episodic reward). The problem is that the rewards are too close and all between 5 and 6, therefore achieving the optimum episodic reward will be harder.

What scaling methods are recommended? (like min-max scaling or reward ** 3)

How can I emphasize the episodic reward?

I’ll try to find where I found it, but normalizing the rewards has always worked for me. Assuming you have a list of the discounted returns for each action, you subtract the whole list by its average value then divide it by its standard deviation. In Python with NumPy, that would look like:

returns -= np.mean(returns)
returns /= np.std(returns)


This puts the returns in a small and consistent range that keeps learning similar with different rewards.

• I don't understand this, how can we get mean and str from the reward that hasn't revealed itself?? we don't have a returns vector. – fardis nadimi Apr 29 at 11:17
• I tried appending reward to a list and taking mean and std but loss functions after a couple of iterations were giving non... – fardis nadimi Apr 29 at 21:13
• @Fardis Could you please write a bit about how your code works? I want to make sure we are talking about scaling the same data. – S2673 Apr 30 at 0:35
• My code is a DDPG and simply we receive an action and for that action, the environment's reward function will produce a reward(it's my own environment). So for step 1, we have 1 reward sample. therefore taking the mean and std of this reward will be misleading. – fardis nadimi Apr 30 at 20:15
• @Fardis Thanks for explaining. My solution was meant for when the network is updated using multiple samples at the same time. First, have you made sure your code works by testing in a different environment? If it does then there are two ways I can think of to use my scaling suggestion for your method. My understanding is that DDPG will have a list with rewards stored and even if you only update with one reward at a time, you could subtract it by the mean and divide it by the variance of all of the rewards that have been collected. Another way is to change your reward function to output values – S2673 Apr 30 at 21:20