All problems
Heap's Law Vocabulary Size
Problem
Return the Heap's law vocabulary size K * n ** beta for a corpus of n tokens, where K and beta are the law's parameters.
n = 0 yields 0.0.
Hint
Vocabulary grows sublinearly, so beta is usually below 1.
Test cases
case 1
in: [1000,10,0.5]
expected: 316.2277660168379
case 2
in: [0,10,0.5]
expected: 0
case 3
in: [100,5,1]
expected: 500
case 4
in: [10000,20,0.6]
expected: 5023.77286301916
Starter codePython
def heaps_law(n, K, beta):
# Your code here
pass4 test cases · run your code against them in the editor