Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-347

Deterministic Channel Capacity

Problem

Compute the capacity in bits of a deterministic channel given the output symbol produced by each input symbol. The capacity is log2 of the number of distinct outputs that can appear. Return 0.0 for an empty mapping.

Hint

A deterministic channel loses information only by mapping several inputs to the same output.

Test cases

case 1
in: [[0,0,1,1]]
expected: 1
case 2
in: [[0,1,2,3]]
expected: 2
case 3
in: [["a","a"]]
expected: 0
case 4
in: [[]]
expected: 0
case 5
in: [[2,0,1,2,0]]
expected: 1.584962500721156
Starter codePython
import math
def deterministic_channel_capacity(mappings):
    # Your code here
    pass

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