All problems
MOSS Index
Problem
Compute the MOSS index for an arm.
With n = len(rewards) and ratio = max(1, total / n), return mean(rewards) + sqrt(c * log(ratio) / n). An empty reward list or a non-positive total returns 0.0.
Hint
The ratio is clamped at 1 so the log is never negative.
Test cases
case 1
in: [[1,0.5,0.5],30,2]
expected: 1.905640729616613
case 2
in: [[2],1,2]
expected: 2
case 3
in: [[0,1],10,1]
expected: 1.3970612889970506
Starter codePython
def moss_index(rewards, total, c):
# Your code here
pass3 test cases · run your code against them in the editor