Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-331

Undetected Error Fraction

Problem

For a binary linear (n, k) code, return the fraction of nonzero error patterns that pass undetected, which is (2^k - 1)/(2^n - 1). Every nonzero codeword is an undetected error pattern. Assume n >= k >= 1.

Hint

Undetected patterns are exactly the nonzero codewords out of all nonzero words.

Test cases

case 1
in: [7,4]
expected: 0.11811023622047244
case 2
in: [3,1]
expected: 0.14285714285714285
case 3
in: [4,2]
expected: 0.2
case 4
in: [1,1]
expected: 1
case 5
in: [8,4]
expected: 0.058823529411764705
Starter codePython
def undetected_error_fraction(n, k):
    # Your code here
    pass

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