All problems
Witten-Bell Lambda
Problem
Return the Witten-Bell interpolation weight lambda = N1 / (N + N1), where N is the total count and N1 is the number of distinct event types in counts.
Return 0.0 when both N and N1 are 0.
Hint
N is the total event count and N1 is the number of distinct events.
Test cases
case 1
in: [[1,1,2]]
expected: 0.42857142857142855
case 2
in: [[]]
expected: 0
case 3
in: [[0,0]]
expected: 1
case 4
in: [[5]]
expected: 0.16666666666666666
Starter codePython
def witten_bell_lambda(counts):
# Your code here
pass4 test cases · run your code against them in the editor