Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-020

Perplexity from Entropy

Problem

Convert an entropy measured in bits to perplexity:

perplexity = 2^H

The result is the effective number of equally likely outcomes.

Hint

Perplexity is the exponentiation of entropy, undoing the logarithm.

Test cases

case 1
in: [0]
expected: 1
case 2
in: [1]
expected: 2
case 3
in: [4]
expected: 16
case 4
in: [0.5]
expected: 1.4142135623730951
Starter codePython
def perplexity_from_entropy(h):
    # Your code here
    pass

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