All problems
Syndrome Error Probability
Problem
A single-error-correcting block code of length n is sent over a binary symmetric channel with crossover probability p. The syndrome is zero exactly when zero or one bit flipped, so the probability of a nonzero syndrome is 1 - (1 - p)^n - n * p * (1 - p)^(n - 1). Return that probability.
Hint
Subtract the probabilities of exactly zero and exactly one flipped bit from one.
Test cases
case 1
in: [7,0.1]
expected: 0.14969439999999978
case 2
in: [3,0.5]
expected: 0.5
case 3
in: [7,0]
expected: 0
case 4
in: [7,1]
expected: 1
Starter codePython
def syndrome_error_probability(n, p):
# Your code here
pass4 test cases · run your code against them in the editor