All problems
Absolute Discounting
Problem
Return the absolute discounting probability max(count - discount, 0) / context_count.
Return 0.0 when context_count is not positive.
Hint
Subtract the discount, clamp at zero, then normalize by the context total.
Test cases
case 1
in: [3,10,0.5]
expected: 0.25
case 2
in: [0,10,0.5]
expected: 0
case 3
in: [0.5,10,0.5]
expected: 0
case 4
in: [0,0,0.5]
expected: 0
case 5
in: [5,5,1]
expected: 0.8
Starter codePython
def absolute_discounting(count, context_count, discount):
# Your code here
pass5 test cases · run your code against them in the editor