v9.1.1
Menu

Undiscounted Finite-Horizon Return

easyPROReturns, Policies, and Value FunctionsReinforcement LearningRL 1: Foundations

Problem Statement

Compute the undiscounted return of an episode: the plain sum of all rewards collected, i.e. the discounted return with gamma = 1.

G0=∑t=1TRtG_0 = \sum_{t=1}^{T} R_t

Implement undiscounted_return(rewards) returning a Python float.

Example

Input
undiscounted_return([1.0, 2.0, 3.0])
Output
6.0
Reasoning
  • Identify the sequence of rewards collected during the episode from the input: R1=1.0R_1 = 1.0, R2=2.0R_2 = 2.0, and R3=3.0R_3 = 3.0.
  • Compute the undiscounted return by summing these rewards, as the discount factor γ=1\gamma = 1 implies no decay in value over time: G0=1.0+2.0+3.0G_0 = 1.0 + 2.0 + 3.0.
  • Perform the arithmetic addition to find the total accumulated reward: G0=6.0G_0 = 6.0.
  • The final output is 6.0

Constraints

  • 0 <= len(rewards) <= 10000
  • Rewards may be negative or fractional.
  • An empty reward list returns 0.0.

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.