All problems
Secrecy Capacity (Gaussian Wiretap)
Problem
Return the Gaussian wiretap secrecy capacity in bits:
max(0, 0.5 * log2(1 + P / N_main) - 0.5 * log2(1 + P / N_eaves))
If the eavesdropper's channel is better, no positive secret rate is achievable.
Hint
Secrecy needs the legitimate channel to be less noisy than the eavesdropper's.
Test cases
case 1
in: [1,1,1]
expected: 0
case 2
in: [10,1,10]
expected: 1.2297158093186487
case 3
in: [1,1,4]
expected: 0.3390359525563188
case 4
in: [5,2,1]
expected: 0
Starter codePython
import math
def secrecy_capacity(power, noise_main, noise_eaves):
# Your code here
pass4 test cases · run your code against them in the editor