Click4Ai

432.

Easy

Discount Factor Effects

=======================

In reinforcement learning, the discount factor is a hyperparameter that determines how much the agent values future rewards. A higher discount factor means the agent values future rewards more, while a lower discount factor means the agent values future rewards less.

**Example:** Consider a robot arm that needs to pick up a block. If the discount factor is 0.9, the agent will value the reward for picking up the block more than the reward for dropping it. However, if the discount factor is 0.1, the agent will value the reward for dropping the block more than the reward for picking it up.

**Constraints:** The discount factor should be a value between 0 and 1.

**Your Task:** Implement a function that calculates the discounted reward for a given sequence of rewards and a discount factor.

Test Cases

Test Case 1
Input: [1, 2, 3]
Expected: 5.0
Test Case 2
Input: [4, 5, 6]
Expected: 15.0
+ 3 hidden test cases