Level 2 — RecallReinforcement Learning Foundations

Reinforcement Learning Foundations

30 minutes40 marksprintable — key stays hidden on paper

Time limit: 30 minutes Total marks: 40 Instructions: Answer all questions. Use ...... notation for mathematics. Show working where derivations are required.


Q1. Define the following components of a reinforcement learning problem in one sentence each: (a) agent, (b) environment, (c) state, (d) action, (e) reward. (5 marks)

Q2. A Markov Decision Process (MDP) is defined as a tuple (S,A,P,R,γ)(S, A, P, R, \gamma). State what each of the five elements represents, and write down the Markov property for the state transition. (6 marks)

Q3. Write the definition of the discounted return GtG_t in terms of future rewards. Given a reward sequence Rt+1=2, Rt+2=4, Rt+3=8R_{t+1}=2,\ R_{t+2}=4,\ R_{t+3}=8 (and zero thereafter) with discount factor γ=0.5\gamma = 0.5, compute GtG_t. (4 marks)

Q4. State the Bellman expectation equation for the state-value function vπ(s)v_\pi(s). Briefly explain the difference between the state-value function vπ(s)v_\pi(s) and the action-value function qπ(s,a)q_\pi(s,a). (5 marks)

Q5. Explain the exploration vs exploitation trade-off in one or two sentences. Then, for an ϵ\epsilon-greedy policy with ϵ=0.1\epsilon = 0.1 over 44 available actions, compute the probability of selecting (a) the current greedy action and (b) a specific non-greedy action. (4 marks)

Q6. State two key differences between Monte Carlo (MC) methods and Temporal Difference (TD) methods for value estimation. (4 marks)

Q7. Write down the TD(0) update rule for V(St)V(S_t), clearly labelling the TD target and the TD error. (3 marks)

Q8. Both SARSA and Q-learning update action-values. Write the update rule for each and state which one is on-policy and which is off-policy. (5 marks)

Q9. Briefly distinguish between policy iteration and value iteration in dynamic programming. (4 marks)


End of paper

Answer keyMark scheme & solutions

Q1. (5 marks) — 1 mark each.

  • (a) Agent: the decision-maker/learner that selects actions to maximise cumulative reward.
  • (b) Environment: everything outside the agent; it responds to actions with new states and rewards.
  • (c) State: a representation of the situation of the environment at a given time step, sSs \in S.
  • (d) Action: a choice available to the agent, aAa \in A, that influences the environment.
  • (e) Reward: a scalar feedback signal RR indicating the immediate value of the agent's action.

Why: these are the standard five primitives defining the agent–environment interaction loop.


Q2. (6 marks) — 1 mark per element (5) + 1 mark for Markov property.

  • SS: set of states (state space).
  • AA: set of actions (action space).
  • PP: transition probability, P(ss,a)=Pr[St+1=sSt=s,At=a]P(s'\mid s,a)=\Pr[S_{t+1}=s'\mid S_t=s, A_t=a].
  • RR: reward function, expected reward R(s,a)R(s,a) (or R(s,a,s)R(s,a,s')).
  • γ\gamma: discount factor, γ[0,1]\gamma \in [0,1].
  • Markov property: Pr[St+1St,At]=Pr[St+1S1,A1,,St,At]\Pr[S_{t+1}\mid S_t, A_t] = \Pr[S_{t+1}\mid S_1,A_1,\dots,S_t,A_t] i.e. the next state depends only on the current state and action, not the full history.

Q3. (4 marks) Definition (1 mark): Gt=Rt+1+γRt+2+γ2Rt+3+=k=0γkRt+k+1G_t = R_{t+1} + \gamma R_{t+2} + \gamma^2 R_{t+3} + \dots = \sum_{k=0}^{\infty}\gamma^k R_{t+k+1} Computation (3 marks): Gt=2+0.5(4)+0.25(8)=2+2+2=6G_t = 2 + 0.5(4) + 0.25(8) = 2 + 2 + 2 = 6 Why: each future reward is weighted by an increasing power of γ\gamma, reflecting reduced value of delayed rewards. Answer: Gt=6G_t = 6.


Q4. (5 marks) Bellman expectation equation (3 marks): vπ(s)=aπ(as)s,rP(s,rs,a)[r+γvπ(s)]v_\pi(s) = \sum_{a}\pi(a\mid s)\sum_{s',r}P(s',r\mid s,a)\big[r + \gamma v_\pi(s')\big] Difference (2 marks):

  • vπ(s)v_\pi(s): expected return starting from state ss and following policy π\pi.
  • qπ(s,a)q_\pi(s,a): expected return starting from state ss, taking action aa, then following π\pi. Relation: vπ(s)=aπ(as)qπ(s,a)v_\pi(s)=\sum_a \pi(a\mid s)\,q_\pi(s,a).

Q5. (4 marks) Trade-off (2 marks): Exploitation uses current knowledge to pick the best-known action for immediate reward; exploration tries other actions to gain information that may yield higher long-term reward. The agent must balance the two.

Computation (2 marks): With ϵ=0.1\epsilon=0.1, A=4|A|=4:

  • (a) Greedy action: P=(1ϵ)+ϵ/A=0.9+0.1/4=0.925P = (1-\epsilon) + \epsilon/|A| = 0.9 + 0.1/4 = 0.925.
  • (b) A specific non-greedy action: P=ϵ/A=0.1/4=0.025P = \epsilon/|A| = 0.1/4 = 0.025.

Check: 0.925+3(0.025)=1.00.925 + 3(0.025) = 1.0. ✓


Q6. (4 marks) — 2 marks per valid difference.

  • MC updates only at the end of an episode using the full observed return GtG_t; TD updates every step using bootstrapping (an estimate of future value).
  • MC requires complete episodes (episodic tasks); TD works online and in continuing tasks.
  • (Alt.) MC has higher variance/no bias; TD has lower variance but introduces bias from bootstrapping.

Q7. (3 marks) V(St)V(St)+α[Rt+1+γV(St+1)TD targetV(St)]V(S_t) \leftarrow V(S_t) + \alpha\Big[\underbrace{R_{t+1}+\gamma V(S_{t+1})}_{\text{TD target}} - V(S_t)\Big]

  • TD error: δt=Rt+1+γV(St+1)V(St)\delta_t = R_{t+1}+\gamma V(S_{t+1}) - V(S_t) (1 mark)
  • Correct update form with α\alpha (1 mark), correct target labelled (1 mark).

Q8. (5 marks) SARSA (2 marks): Q(St,At)Q(St,At)+α[Rt+1+γQ(St+1,At+1)Q(St,At)]Q(S_t,A_t)\leftarrow Q(S_t,A_t)+\alpha\big[R_{t+1}+\gamma Q(S_{t+1},A_{t+1})-Q(S_t,A_t)\big] Q-learning (2 marks): Q(St,At)Q(St,At)+α[Rt+1+γmaxaQ(St+1,a)Q(St,At)]Q(S_t,A_t)\leftarrow Q(S_t,A_t)+\alpha\big[R_{t+1}+\gamma \max_{a}Q(S_{t+1},a)-Q(S_t,A_t)\big] Classification (1 mark): SARSA is on-policy (uses the action At+1A_{t+1} actually taken); Q-learning is off-policy (uses the greedy max\max regardless of behaviour policy).


Q9. (4 marks) — 2 marks each.

  • Policy iteration: alternates full policy evaluation (solve for vπv_\pi) and policy improvement (greedy update) until the policy is stable.
  • Value iteration: applies the Bellman optimality update directly, effectively truncating evaluation to a single sweep per iteration; converges to vv_*, then extracts the greedy policy.

[
  {"claim":"Q3 discounted return equals 6","code":"g=0.5; G=2+g*4+g**2*8; result=(G==6)"},
  {"claim":"Q5a epsilon-greedy greedy action prob equals 0.925","code":"eps=0.1; A=4; p=(1-eps)+eps/A; result=(abs(p-0.925)<1e-9)"},
  {"claim":"Q5b non-greedy action prob equals 0.025","code":"eps=0.1; A=4; p=eps/A; result=(abs(p-0.025)<1e-9)"},
  {"claim":"Q5 probabilities sum to 1","code":"eps=0.1; A=4; pg=(1-eps)+eps/A; pn=eps/A; total=pg+(A-1)*pn; result=(abs(total-1)<1e-9)"}
]