Reinforcement Learning Introduction
- 28Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What are the four components that define a Markov decision process (MDP)?
28 questions
- 1
What are the four components that define a Markov decision process (MDP)?
Model answer
A Markov decision process is defined by the state space, action space, transition probability p(s′∣s,a), and reward function R(s,a).
Explanation
The MDP models an environment where the agent moves between states based on actions, with probabilistic transitions and immediate rewards. The transition probability and reward function together define the dynamics.
- 2
In an MDP, what does the transition probability p(s′∣s,a) represent?
Model answer
It represents the probability that the environment transitions to state s′ given the agent is in state s and takes action a.
Explanation
This captures the stochastic nature of the environment: the same action in the same state can lead to different next states according to this probability distribution.
- 3
What is the reward function in an MDP and what does it depend on?
Model answer
The reward function gives the immediate reward received after transitioning from state s due to action a, often denoted R(s,a).
Explanation
It specifies the objective the agent aims to maximize over time, typically depending on the current state and action taken.
- 4
Define the quality function Q(s,a) in reinforcement learning.
Model answer
Q(s,a) is the expected discounted cumulative future reward when starting in state s, taking action a, and thereafter following the optimal policy.
Explanation
It measures the long-term value of a state-action pair, incorporating both immediate and future rewards discounted by factor γ.
- 5
How is the value function V(s) related to the quality function Q(s,a)?
Model answer
V(s)=maxaQ(s,a); it is the quality of the best action in state s.
Explanation
The value function assumes the agent always chooses the action that maximizes expected return from that state onward.
- 6
Write the Bellman optimality equation for the quality function Q(s,a).
Model answer
Q(s,a)=E[R(s,a)+γmaxa′Q(s′,a′)] where the expectation is over the next state s′ according to p(s′∣s,a).
Explanation
This recursive relationship expresses the optimal Q-value in terms of the immediate expected reward plus the discounted optimal Q-value of the next state.
- 7
How can the optimal policy π∗(s) be derived from the quality function?
Model answer
π∗(s)=argmaxaQ(s,a); the optimal action in state s is the one that maximizes Q(s,a).
Explanation
Once Q is known, the greedy policy of always picking the highest Q-value yields optimal behavior.
- 8
What is the key difference between model-based and model-free reinforcement learning?
Model answer
Model-based methods assume knowledge of the MDP transition probabilities and reward function, while model-free methods learn directly from experience without a model.
Explanation
Model-free approaches rely on trial-and-error interaction, making them applicable when the environment dynamics are unknown or too complex to model explicitly.
- 9
Why might model-free reinforcement learning be necessary in many real-world problems?
Model answer
Because we often do not have access to transition probabilities or the reward function a priori; we must learn by interacting with the environment.
Explanation
For example, in games like chess, the rules may be known, but the value of each state is unknown and must be learned through experience.
- 10
What is the defining characteristic of Monte Carlo learning algorithms?
Model answer
Monte Carlo methods are episodic: they wait until the end of an episode to update value or quality estimates using the total cumulative reward.
Explanation
They rely on complete trajectories, so they are not suitable for continuing tasks without defined ends.
- 11
Write the Monte Carlo update rule for the value function V(s) after an episode.
Model answer
V(s)←V(s)+α(NRtotal−V(s)) for each state visited, where Rtotal is the cumulative discounted reward and N is the number of steps.
Explanation
The reward is divided equally among all states visited, so each state gets the same average credit for the episode's outcome.
- 12
State one advantage and one disadvantage of Monte Carlo learning.
Model answer
Advantage: it is unbiased (estimates converge to true values given enough episodes). Disadvantage: it is sample-inefficient and requires many episodes to learn.
Explanation
Its unbiasedness comes from using actual returns, but the high variance and need for complete episodes makes learning slow.
- 13
What is the TD(0) update rule for the value function V(sk)?
Model answer
V(sk)←V(sk)+α(rk+γV(sk+1)−V(sk)), where rk+γV(sk+1) is the TD target.
Explanation
This uses the immediate reward and the estimated value of the next state to update the current state's value, bootstrapping from the current estimate.
- 14
Define the TD error in temporal difference learning.
Model answer
The TD error is δk=rk+γV(sk+1)−V(sk), the difference between the TD target and the current estimate.
Explanation
A positive error means the actual reward was higher than expected, so the value estimate should increase for the current state-action pair.
- 15
How does n-step temporal difference learning differ from TD(0)?
Model answer
n-step TD uses a target that includes rewards for the next n steps and the value estimate n steps ahead: ∑i=0n−1γirk+i+γnV(sk+n).
Explanation
It waits n steps to incorporate more actual rewards before bootstrapping, trading off bias and variance. As n→∞, it approaches Monte Carlo.
- 16
What is TD(λ) and how does it combine different n-step returns?
Model answer
TD(λ) uses an exponentially weighted average of all n-step returns with weights (1−λ)λn−1 for n≥1.
Explanation
The parameter λ∈[0,1] controls how much credit is given to recent versus distant events, interpolating between TD(0) (λ=0) and Monte Carlo (λ=1).
- 17
What biological evidence is there for TD learning?
Model answer
Dopamine release in the brain is believed to encode the TD error, strengthening connections between neurons that fired shortly before a reward.
Explanation
This neural mechanism allows organisms to learn associations between cues and rewards over time, paralleling the TD update rule.
- 18
Write the Q-learning update rule.
Model answer
Q(sk,ak)←Q(sk,ak)+α(rk+γmaxa′Q(sk+1,a′)−Q(sk,ak)).
Explanation
This is the TD update applied to the Q-function, using the maximum Q-value over actions in the next state to compute the target, making it off-policy.
- 19
Write the SARSA update rule.
Model answer
Q(sk,ak)←Q(sk,ak)+α(rk+γQ(sk+1,ak+1)−Q(sk,ak)), where ak+1 is the actual action taken in the next state.
Explanation
Unlike Q-learning, SARSA uses the Q-value of the action actually chosen in the next state, making it on-policy.
- 20
What makes Q-learning an off-policy algorithm?
Model answer
It uses the maximum over actions in the next state (maxa′Q(sk+1,a′)) to compute the target, independent of the action actually taken, allowing learning from suboptimal behavior.
Explanation
The target does not depend on the policy used to generate the experience, so the agent can learn from any data, including past episodes or demonstrations.
- 21
What makes SARSA an on-policy algorithm?
Model answer
It uses the Q-value of the actual next action taken (Q(sk+1,ak+1)) to compute the target, so the learned Q-function reflects the policy being followed.
Explanation
This means SARSA learns the value of the current policy and is sensitive to exploration moves; it cannot learn from off-policy data without corrupting estimates.
- 22
State one advantage of SARSA over Q-learning.
Model answer
SARSA is safer during training because it always acts according to its current policy, avoiding dangerous exploratory actions, and thus yields higher cumulative reward during learning.
Explanation
Since SARSA does not use random actions for exploration (if using greedy policy), it maintains more consistent behavior, which is crucial in safety-critical applications like driving.
- 23
State one advantage of Q-learning over SARSA.
Model answer
Q-learning can converge faster to the optimal policy because it can learn from off-policy experiences and explore more efficiently, often finding better solutions in less time.
Explanation
Its off-policy nature allows it to learn from any data, including replay of past experiences or demonstrations, leading to higher sample efficiency.
- 24
Can Q-learning be extended to use n-step or TD(λ) targets? Explain briefly.
Model answer
Yes, the TD target in Q-learning can be replaced by an n-step return or TD(λ) return, as long as the max operation is applied appropriately to the bootstrap part.
Explanation
For example, a 2-step Q-learning target would be rk+γrk+1+γ2maxa′′Q(sk+2,a′′), maintaining off-policy learning.
- 25
Describe the epsilon-greedy exploration strategy.
Model answer
With probability 1−ϵ, the agent selects the greedy action (maximizing Q(s,a)); with probability ϵ, it selects a random action uniformly.
Explanation
This balances exploitation and exploration. Typically ϵ is annealed from a high value (e.g., 1) to a low value (e.g., 0) over time.
- 26
Why is epsilon often decayed over time in Q-learning?
Model answer
To transition from exploration to exploitation: early on, high exploration helps discover good actions; later, low exploration ensures the agent uses its learned policy predominantly.
Explanation
This annealing mimics a cooling schedule in simulated annealing, allowing the agent to converge to an optimal policy after sufficient exploration.
- 27
What is the typical variance comparison between Q-learning and SARSA?
Model answer
Q-learning often has higher variance than SARSA because it uses the max operator, which can overestimate Q-values and introduce more variability.
Explanation
The max over actions in the target amplifies positive estimation errors, leading to high variance unless techniques like double Q-learning are used.
- 28
What is the primary reason Q-learning can be more sample-efficient than Monte Carlo methods?
Model answer
Q-learning updates using bootstrapping from current estimates after each step, so it learns continuously within an episode, unlike Monte Carlo which must wait for the episode to end.
Explanation
Bootstrapping allows information to propagate backward more quickly, reducing the number of required episodes, though it introduces bias.

Ask anything
We've read this whole study set, so questions about it get the best answers.