All problems
Epsilon-Greedy Choice
Problem
Choose an arm with epsilon-greedy. Call random.seed(seed); with probability epsilon pick a uniformly random arm, otherwise pick the arm with the largest value (ties keep the smallest index).
Empty values return -1.
Hint
Epsilon controls how often the policy explores instead of exploiting.
Test cases
case 1
in: [[1,3,2],0.1,42]
expected: 1
case 2
in: [[1,3,2],1,7]
expected: 0
case 3
in: [[1,3,2],0.5,0]
expected: 1
case 4
in: [[5,5],0,7]
expected: 0
Starter codePython
import random
def epsilon_greedy_choice(values, epsilon, seed):
# Your code here
pass4 test cases · run your code against them in the editor