Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-138

Redundancy of Language

Problem

Return the redundancy of a source as 1 - H / H_max, where H is its actual entropy in bits and H_max the entropy of a uniform source with the same alphabet. A redundancy of 0.75 means only a quarter of the capacity is used.

Hint

A uniform source has zero redundancy.

Test cases

case 1
in: [1,4]
expected: 0.75
case 2
in: [2,2]
expected: 0
case 3
in: [0,4]
expected: 1
case 4
in: [4.7,4.7]
expected: 0
Starter codePython
def language_redundancy(entropy_bits, max_entropy_bits):
    # Your code here
    pass

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