Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-094

UCB Exploration Term

Problem

Compute the UCB exploration bonus for one arm.

Return c * sqrt(log(total) / count), or 0.0 when count <= 0 or total <= 1. Here total is the number of pulls across all arms and count is this arm's pull count.

Hint

The bonus grows with log(total) and shrinks as the arm is pulled more.

Test cases

case 1
in: [5,100,1]
expected: 0.9597051824376163
case 2
in: [1,10,2]
expected: 3.034854258770293
case 3
in: [0,10,1]
expected: 0
case 4
in: [3,1,1]
expected: 0
Starter codePython
def ucb_exploration_term(count, total, c):
    # Your code here
    pass

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