Skip to content
DeepForgeby svx
All problems
HardInformation Theoryinfo-116

Repetition Code BER

Problem

Return the post-decoding bit error rate of a length-n repetition code with majority decoding over a BSC with crossover p:

P_e = sum_{i=(n+1)/2}^{n} C(n, i) * p^i * (1 - p)^(n - i)

Assume n is odd.

Hint

An error survives majority decoding only when more than half the bits flip.

Test cases

case 1
in: [0.1,3]
expected: 0.028000000000000008
case 2
in: [0.5,3]
expected: 0.5
case 3
in: [0.1,5]
expected: 0.008560000000000002
case 4
in: [0.2,3]
expected: 0.10400000000000004
Starter codePython
import math
def repetition_ber(p, n):
    # Your code here
    pass

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