All problems
Compression Rate Bound
Problem
Check Shannon's source coding bound: return True when the coder's rate in bits is at least the source entropy in bits (within 1e-9). No lossless coder can beat the entropy on average.
Hint
Entropy is the fundamental limit of lossless compression.
Test cases
case 1
in: [2,2]
expected: true
case 2
in: [2,3]
expected: true
case 3
in: [2,1.5]
expected: false
case 4
in: [0,0]
expected: true
Starter codePython
def compression_rate_bound(entropy_bits, coder_bits):
# Your code here
pass4 test cases · run your code against them in the editor