Skip to content
StackDecode
AI & ML Atlas
Reinforcement LearningalgorithmInteractive simulation

Epsilon-Greedy Algorithm

Take the best-known action most of the time and a random one with probability ε.

The idea

With probability 1 − ε exploit (choose the action with the highest estimated value); with probability ε explore (choose uniformly at random). It is trivial to implement. ε is usually decayed, say from 1.0 to 0.05, so the agent explores a lot early and exploits later.

a = random with prob. ε, else argmax Q(s, a)

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

total regret (reward lost by not always playing the best arm)pulled 1×arm 1pulled 0×arm 2pulled 0×arm 3pulled 0×arm 4pulled 0×arm 5
  • estimated value
  • true value (dashed)
  • arm just pulled

Pull 1: Exploit: pick the arm that looks best so far. Got reward 0.51.

pulls:
1
regret:
0.84
1/40

Bars are what the agent believes; dashed lines are the truth it is trying to discover.

Step by step

  1. 1Draw a random number between 0 and 1.
  2. 2If it is below ε, pick a random action.
  3. 3Otherwise pick the action with the highest estimated value.
  4. 4Observe the reward, update the estimate, lower ε a little.

Where it is used

The default exploration in Q-learning and DQN.

Watch out for

Explores blindly: it wastes tries on options already known to be bad.

Related