Skip to content
DeepForgeby svx
All problems

Advantage Function

Problem

Compute the advantage of each action: A(s,a) = Q(s,a) - V(s). Return a list with the same length as Q_values.

Hint

The value function is the baseline; advantages say which actions beat it.

Test cases

case 1
in: [[1,2,3],2]
expected: [-1,0,1]
case 2
in: [[0,0],0]
expected: [0,0]
case 3
in: [[-1,5],3]
expected: [-4,2]
case 4
in: [[],1]
expected: []
Starter codePython
def advantage_function(Q_values, state_value):
    # Your code here
    pass

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