Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Master the fundamental trade-off: exploiting known high-value actions versus exploring uncertain actions to discover even greater rewards.
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Estimated reward | Exploitation term | |
| Uncertainty bonus | Exploration term | |
| Count of times action a was tried | Less tried = higher bonus |
Action 1 tried 100 times with Q=8. Action 2 tried only 2 times with Q=7. Action 2 gets a massive uncertainty bonus and gets chosen.
Result: Optimism in the face of uncertainty
Draw uniform random number r between 0.0 and 1.0.
If r < epsilon, pick random action (Explore); otherwise pick argmax Q(s,a) (Exploit).
Multiply epsilon by decay factor (e.g. 0.995) after each episode.
Problem: Showing 5 different website landing page designs to find the highest conversion rate.
Solution: Multi-Armed Bandit algorithms route more traffic to winning designs while continuing to explore others.
Interactive activity component
Simulate epsilon decay over 100 episodes and visualize action choices.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install numpy1 import numpy as np
import numpy as np β NumPy for random choices
1 epsilon = 1.0 # Start with 100% exploration 2 epsilon_min = 0.05 # Keep 5% minimum exploration 3 decay_rate = 0.95 # Decay 5% every episode 4 5 exploration_count = 0 6 exploitation_count = 0 7 8 for episode in range(100): 9 # Epsilon-greedy check: 10 if np.random.rand() < epsilon: 11 exploration_count += 1 12 else: 13 exploitation_count += 1 14 # Decay epsilon after episode: 15 epsilon = max(epsilon_min, epsilon * decay_rate) 16 17 print(f"Final Epsilon: {epsilon:.3f}") 18 print(f"Total Explores: {exploration_count}, Total Exploits: {exploitation_count}")
epsilon = 1.0 # Start with 100% exploration
Initial epsilon
epsilon_min = 0.05 # Keep 5% minimum exploration
Floor
decay_rate = 0.95 # Decay 5% every episode
Decay factor
exploration_count = 0
Counter
exploitation_count = 0
Counter
for episode in range(100):
100 episodes
# Epsilon-greedy check:
Check
if np.random.rand() < epsilon:
Explore branch
exploration_count += 1
Count explore
else:
Exploit branch
exploitation_count += 1
Count exploit
# Decay epsilon after episode:
Decay step
epsilon = max(epsilon_min, epsilon * decay_rate)
Apply decay
print(f"Final Epsilon: {epsilon:.3f}")
Show final epsilon
print(f"Total Explores: {exploration_count}, Total Exploits: {exploitation_count}")
Show breakdown
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Epsilon-Decay Implementation in Python 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install numpy 8 9 # Step 2: Import libraries 10 import numpy as np 11 12 # Step 3: Run Demonstration 13 epsilon = 1.0 # Start with 100% exploration 14 epsilon_min = 0.05 # Keep 5% minimum exploration 15 decay_rate = 0.95 # Decay 5% every episode 16 17 exploration_count = 0 18 exploitation_count = 0 19 20 for episode in range(100): 21 # Epsilon-greedy check: 22 if np.random.rand() < epsilon: 23 exploration_count += 1 24 else: 25 exploitation_count += 1 26 # Decay epsilon after episode: 27 epsilon = max(epsilon_min, epsilon * decay_rate) 28 29 print(f"Final Epsilon: {epsilon:.3f}") 30 print(f"Total Explores: {exploration_count}, Total Exploits: {exploitation_count}")
High epsilon drives aggressive exploration.
Epsilon drops to 0.05, and the agent exploits 95% of the time.
100 episodes with initial epsilon 1.0 and decay 0.95
Final Epsilon: 0.050 Total Explores: ~24, Total Exploits: ~76
Epsilon decay seamlessly transitions the agent from a curious explorer into an efficient optimizer.
Q-learning, Q-table updates, DQN architectures, and exploration-exploitation trade-offs.
Test your understanding with these questions. Remember, this is for learning, not examination!