All problems
Negative Sampling Probability
Problem
Return the negative-sampling distribution over vocabulary items with the given counts: p_i = count_i ** 0.75 divided by the sum of count ** 0.75 over all items.
Return an empty list for empty input, and all zeros when every count is 0.
Hint
The 0.75 power flattens frequent words before normalizing.
Test cases
case 1
in: [[1,1,1,1]]
expected: [0.25,0.25,0.25,0.25]
case 2
in: [[4,1]]
expected: [0.7387961250362586,0.2612038749637414]
case 3
in: [[]]
expected: []
case 4
in: [[0,1]]
expected: [0,1]
case 5
in: [[9]]
expected: [1]
Starter codePython
def negative_sampling_prob(counts):
# Your code here
pass5 test cases · run your code against them in the editor