All problems
State-Value From Action Values
Problem
Compute the state value V(s) as the expectation of action values under a policy: V(s) = sum_a probs[a] * Q[a]. Empty inputs return 0.0.
Hint
This is just a dot product between the policy probabilities and the action values.
Test cases
case 1
in: [[1,2,3],[0.2,0.3,0.5]]
expected: 2.3
case 2
in: [[5],[1]]
expected: 5
case 3
in: [[1,0],[0.5,0.5]]
expected: 0.5
case 4
in: [[],[]]
expected: 0
Starter codePython
def state_value_from_q(Q, probs):
# Your code here
pass4 test cases · run your code against them in the editor