Skip to content
DeepForgeby svx
All problems

Average Reward Optimality

Problem

Compute the average reward (gain) of a policy from its stationary distribution and per-state rewards: sum of d[s] * rewards[s].

Hint

Under the average-reward criterion the gain is the stationary-weighted mean reward.

Test cases

case 1
in: [[0.5,0.5],[2,4]]
expected: 3
case 2
in: [[1,0],[1,10]]
expected: 1
case 3
in: [[0.25,0.25,0.5],[1,2,3]]
expected: 2.25
Starter codePython
def average_reward(d, rewards):
    # Your code here
    pass

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