1. Home
  2. Explore
  3. Computer Science
  4. Reinforcement Learning Introduction

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Reinforcement Learning Introduction

  • 28Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Markov Decision Processes

What are the four components that define a Markov decision process (MDP)?

28 questions

  1. 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)p(s' | s, a)p(s′∣s,a), and reward function R(s,a)R(s, a)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. 2

    In an MDP, what does the transition probability p(s′∣s,a)p(s' | s, a)p(s′∣s,a) represent?

    Model answer

    It represents the probability that the environment transitions to state s′s's′ given the agent is in state sss and takes action aaa.

    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. 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 sss due to action aaa, often denoted R(s,a)R(s, a)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. 4

    Define the quality function Q(s,a)Q(s, a)Q(s,a) in reinforcement learning.

    Model answer

    Q(s,a)Q(s, a)Q(s,a) is the expected discounted cumulative future reward when starting in state sss, taking action aaa, 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 γ\gammaγ.

  5. 5

    How is the value function V(s)V(s)V(s) related to the quality function Q(s,a)Q(s, a)Q(s,a)?

    Model answer

    V(s)=max⁡aQ(s,a)V(s) = \max_a Q(s, a)V(s)=maxa​Q(s,a); it is the quality of the best action in state sss.

    Explanation

    The value function assumes the agent always chooses the action that maximizes expected return from that state onward.

  6. 6

    Write the Bellman optimality equation for the quality function Q(s,a)Q(s, a)Q(s,a).

    Model answer

    Q(s,a)=E[R(s,a)+γmax⁡a′Q(s′,a′)]Q(s, a) = \mathbb{E}[R(s, a) + \gamma \max_{a'} Q(s', a')]Q(s,a)=E[R(s,a)+γmaxa′​Q(s′,a′)] where the expectation is over the next state s′s's′ according to p(s′∣s,a)p(s'|s,a)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. 7

    How can the optimal policy π∗(s)\pi^*(s)π∗(s) be derived from the quality function?

    Model answer

    π∗(s)=arg⁡max⁡aQ(s,a)\pi^*(s) = \arg\max_a Q(s, a)π∗(s)=argmaxa​Q(s,a); the optimal action in state sss is the one that maximizes Q(s,a)Q(s,a)Q(s,a).

    Explanation

    Once Q is known, the greedy policy of always picking the highest Q-value yields optimal behavior.

  8. 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. 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. 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. 11

    Write the Monte Carlo update rule for the value function V(s)V(s)V(s) after an episode.

    Model answer

    V(s)←V(s)+α(RtotalN−V(s))V(s) \leftarrow V(s) + \alpha \left( \frac{R_{\text{total}}}{N} - V(s) \right)V(s)←V(s)+α(NRtotal​​−V(s)) for each state visited, where RtotalR_{\text{total}}Rtotal​ is the cumulative discounted reward and NNN 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. 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. 13

    What is the TD(0) update rule for the value function V(sk)V(s_k)V(sk​)?

    Model answer

    V(sk)←V(sk)+α(rk+γV(sk+1)−V(sk))V(s_k) \leftarrow V(s_k) + \alpha \left( r_k + \gamma V(s_{k+1}) - V(s_k) \right)V(sk​)←V(sk​)+α(rk​+γV(sk+1​)−V(sk​)), where rk+γV(sk+1)r_k + \gamma V(s_{k+1})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. 14

    Define the TD error in temporal difference learning.

    Model answer

    The TD error is δk=rk+γV(sk+1)−V(sk)\delta_k = r_k + \gamma V(s_{k+1}) - V(s_k)δ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. 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)\sum_{i=0}^{n-1} \gamma^i r_{k+i} + \gamma^n V(s_{k+n})∑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→∞n \to \inftyn→∞, it approaches Monte Carlo.

  16. 16

    What is TD(λ\lambdaλ) and how does it combine different n-step returns?

    Model answer

    TD(λ\lambdaλ) uses an exponentially weighted average of all n-step returns with weights (1−λ)λn−1(1-\lambda)\lambda^{n-1}(1−λ)λn−1 for n≥1n \geq 1n≥1.

    Explanation

    The parameter λ∈[0,1]\lambda \in [0,1]λ∈[0,1] controls how much credit is given to recent versus distant events, interpolating between TD(0) (λ=0\lambda=0λ=0) and Monte Carlo (λ=1\lambda=1λ=1).

  17. 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. 18

    Write the Q-learning update rule.

    Model answer

    Q(sk,ak)←Q(sk,ak)+α(rk+γmax⁡a′Q(sk+1,a′)−Q(sk,ak))Q(s_k, a_k) \leftarrow Q(s_k, a_k) + \alpha \left( r_k + \gamma \max_{a'} Q(s_{k+1}, a') - Q(s_k, a_k) \right)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. 19

    Write the SARSA update rule.

    Model answer

    Q(sk,ak)←Q(sk,ak)+α(rk+γQ(sk+1,ak+1)−Q(sk,ak))Q(s_k, a_k) \leftarrow Q(s_k, a_k) + \alpha \left( r_k + \gamma Q(s_{k+1}, a_{k+1}) - Q(s_k, a_k) \right)Q(sk​,ak​)←Q(sk​,ak​)+α(rk​+γQ(sk+1​,ak+1​)−Q(sk​,ak​)), where ak+1a_{k+1}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. 20

    What makes Q-learning an off-policy algorithm?

    Model answer

    It uses the maximum over actions in the next state (max⁡a′Q(sk+1,a′)\max_{a'} Q(s_{k+1}, a')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. 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)Q(s_{k+1}, a_{k+1})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. 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. 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. 24

    Can Q-learning be extended to use n-step or TD(λ\lambdaλ) targets? Explain briefly.

    Model answer

    Yes, the TD target in Q-learning can be replaced by an n-step return or TD(λ\lambdaλ) 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+γ2max⁡a′′Q(sk+2,a′′)r_k + \gamma r_{k+1} + \gamma^2 \max_{a''} Q(s_{k+2}, a'')rk​+γrk+1​+γ2maxa′′​Q(sk+2​,a′′), maintaining off-policy learning.

  25. 25

    Describe the epsilon-greedy exploration strategy.

    Model answer

    With probability 1−ϵ1-\epsilon1−ϵ, the agent selects the greedy action (maximizing Q(s,a)Q(s,a)Q(s,a)); with probability ϵ\epsilonϵ, it selects a random action uniformly.

    Explanation

    This balances exploitation and exploration. Typically ϵ\epsilonϵ is annealed from a high value (e.g., 1) to a low value (e.g., 0) over time.

  26. 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. 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. 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.

1 of 28
Question 1 of 28

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent