All problems
AND Channel Capacity
Problem
Compute the capacity in bits of the channel Y = X AND Z, where X is the binary input and Z is an independent Bernoulli noise bit with P(Z = 1) = q. When Z is 0 the output is forced to 0, so the channel is an erasure-like model whose capacity is 1.0 for q <= 0.5 and H2(1 - q) otherwise.
Hint
Given X the output is deterministic, so maximize the entropy of P(Y = 1) = p(1 - q) over the input bias p.
Test cases
case 1
in: [0]
expected: 1
case 2
in: [0.25]
expected: 1
case 3
in: [0.75]
expected: 0.8112781244591328
case 4
in: [1]
expected: 0
case 5
in: [0.5]
expected: 1
Starter codePython
import math
def and_channel_capacity(q):
# Your code here
pass5 test cases · run your code against them in the editor