Skip to content
DeepForgeby svx
All problems

Backup Value At Leaf

Problem

Back up a leaf value into a node's running average.

Return (total_value + leaf_value) / (visits + 1), the new mean action value after one more visit.

Hint

Incremental averaging keeps the node's Q estimate exact.

Test cases

case 1
in: [10,2,4]
expected: 4.666666666666667
case 2
in: [0,0,3]
expected: 3
case 3
in: [-2,3,-6]
expected: -2
Starter codePython
def backup_value_at_leaf(total_value, visits, leaf_value):
    # Your code here
    pass

3 test cases · run your code against them in the editor