All problems
Zipf Expected Frequency
Problem
Return the Zipf law expected frequency C / rank ** s for a word at the given rank.
rank is 1-based, C is the constant of proportionality, and s is the exponent. rank is assumed to be positive.
Hint
A rank exponent of 1 gives the classic 1/rank decay.
Test cases
case 1
in: [1,100,1]
expected: 100
case 2
in: [2,100,1]
expected: 50
case 3
in: [1,50,2]
expected: 50
case 4
in: [4,64,1.5]
expected: 8
case 5
in: [2,10,0]
expected: 10
Starter codePython
def zipf_frequency(rank, C, s):
# Your code here
pass5 test cases · run your code against them in the editor