Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-054

Compression Ratio Proxy

Problem

Return a simple compression ratio proxy: the source entropy in bits per symbol divided by the raw bits per symbol. The result lies in (0, 1] for a compressible source.

Hint

This is the fraction of the raw bit rate that an ideal entropy coder needs.

Test cases

case 1
in: [1,8]
expected: 0.125
case 2
in: [4,4]
expected: 1
case 3
in: [2,8]
expected: 0.25
case 4
in: [0,8]
expected: 0
Starter codePython
def compression_ratio(entropy_bits, raw_bits):
    # Your code here
    pass

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