v9.1.1
Menu

One-Step Bellman Expectation Backup

mediumPROMarkov Decision Processes and Bellman EquationsReinforcement LearningRL 1: Foundations

Problem Statement

Perform a single Bellman expectation backup for one state-action pair, given the current value estimates of the next states:

Q(s,a)=R(s,a)+γ∑s′P(s′∣s,a) V(s′)Q(s,a) = R(s,a) + \gamma \sum_{s'} P(s'\mid s,a)\, V(s')

Implement bellman_backup(reward, gamma, probs, values) where probs and values are aligned lists over next states.

Example

Input
bellman_backup(1.0, 0.9, [0.5, 0.5], [10.0, 0.0])
Output
5.5
Reasoning
  • Compute the expected value of the next states by taking the dot product of the transition probabilities and the corresponding state values: 0.5×10.0+0.5×0.0=5.00.5 \times 10.0 + 0.5 \times 0.0 = 5.0.
  • Scale this expectation by the discount factor γ\gamma to account for the reduced importance of future rewards: 0.9×5.0=4.50.9 \times 5.0 = 4.5.
  • Add the immediate reward to the discounted future value to obtain the total Q-value: 1.0+4.5=5.51.0 + 4.5 = 5.5.
  • The final output is 5.5

Constraints

  • len(probs) == len(values), probs sums to 1.
  • Return a float.

Learn this in

More from RL 1: Foundations

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.