REINFORCEMENT LEARNING Β· INTERVIEW QUESTION
Explain the Bellman equation. How is it used in Q-learning?
π‘ intermediate Β· Fundamentals & MDPs
Hint: Think about the recursive relationship between values of successive states.
Answer
Bellman equation expresses value of a state as immediate reward plus discounted future value:
For Q-values (state-action values):
Q-learning is model-free β learns without knowing transition probabilities :
where is the learning rate and is the discount factor.
python
import numpy as np
# Tabular Q-learning
Q = np.zeros((n_states, n_actions))
for episode in range(1000):
s, _ = env.reset()
done = False
while not done:
a = epsilon_greedy(Q, s, epsilon=0.1)
s_next, r, terminated, truncated, _ = env.step(a)
done = terminated or truncated
bootstrap = 0.0 if terminated else Q[s_next].max()
Q[s, a] += alpha * (r + gamma * bootstrap - Q[s, a])
s = s_nextDeep Q-Networks (DQN) replace the Q-table with a neural network for large state spaces.
Related questions
- What is reinforcement learning, and how does it differ from supervised and unsupervised learning?
- Explain the exploration-exploitation tradeoff. What strategies address it?
- Define the terms: agent, environment, state, action, and reward in the context of reinforcement learning.
- Can you explain the concept of the Markov Decision Process (MDP) in reinforcement learning?
- What is the role of a policy in reinforcement learning?