Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-086

Perplexity of Uniform Distribution

Problem

Return the perplexity of a uniform distribution over vocab_size outcomes, which equals the vocabulary size itself as a float: 2^(log2(V)) = V.

Hint

A uniform model is maximally uncertain, so its perplexity is the whole vocabulary.

Test cases

case 1
in: [2]
expected: 2
case 2
in: [10]
expected: 10
case 3
in: [1]
expected: 1
case 4
in: [32000]
expected: 32000
Starter codePython
def uniform_perplexity(vocab_size):
    # Your code here
    pass

4 test cases · run your code against them in the editor