Implement ε-greedy action selection for exploration in reinforcement learning.
ε-Greedy Policy:
a=⎩⎨⎧argmaxaQ(s,a),random action,with probability 1−ε,with probability ε.where ε∈[0,1] controls the exploration rate.
q_values: 1D array, shape (n_actions,) - Q(s, ·) for current stateepsilon: float in [0,1] - exploration probabilityrng: optional np.random.Generator - for deterministic testingInput: q_values=[1,2,0.5], ε=0
Output: action = 1
Input: q_values=[1,2,0.5], ε=1
Output: action ∈ {0,1,2} with equal probability
Generate a random number between 0 and 1. If it's less than ε, choose random action, else choose greedy.
Use np.argmax() for greedy action and rng.integers() or np.random.randint() for random action.
np.randomSign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: any
Implement ε-greedy action selection for exploration in reinforcement learning.
ε-Greedy Policy:
a=⎩⎨⎧argmaxaQ(s,a),random action,with probability 1−ε,with probability ε.where ε∈[0,1] controls the exploration rate.
q_values: 1D array, shape (n_actions,) - Q(s, ·) for current stateepsilon: float in [0,1] - exploration probabilityrng: optional np.random.Generator - for deterministic testingInput: q_values=[1,2,0.5], ε=0
Output: action = 1
Input: q_values=[1,2,0.5], ε=1
Output: action ∈ {0,1,2} with equal probability
Generate a random number between 0 and 1. If it's less than ε, choose random action, else choose greedy.
Use np.argmax() for greedy action and rng.integers() or np.random.randint() for random action.
np.randomSign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: any