All problems
Uniform Distribution Entropy
Problem
Compute the entropy in bits of a uniform distribution over n equally likely outcomes:
H = log2(n)
Return 0.0 for n <= 1.
Hint
The uniform distribution maximizes entropy over a fixed support.
Test cases
case 1
in: [1]
expected: 0
case 2
in: [2]
expected: 1
case 3
in: [8]
expected: 3
case 4
in: [10]
expected: 3.321928094887362
Starter codePython
import math
def uniform_entropy(n):
# Your code here
pass4 test cases · run your code against them in the editor