All problems
Epsilon-Greedy Pick
Problem
Pick an arm with epsilon-greedy exploration.
After random.seed(seed), draw random.random(): if it is below epsilon return random.randrange(len(q_values)); otherwise return the index of the largest q value, with the lowest index winning ties. Exploration and exploitation draws come from the same seeded stream.
Hint
epsilon = 0 is pure exploitation; epsilon = 1 is pure exploration.
Test cases
case 1
in: [[1,2,3],0,1]
expected: 2
case 2
in: [[1,2,3],1,1]
expected: 0
case 3
in: [[0.5,0.5,0.1],0.2,42]
expected: 0
case 4
in: [[3,1],0.5,0]
expected: 0
Starter codePython
def epsilon_greedy_pick(q_values, epsilon, seed):
# Your code here
pass4 test cases · run your code against them in the editor