Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-120

LLR for BSC

Problem

Return the natural-log likelihood ratio of a received bit over a BSC with crossover probability p: log((1 - p) / p) for a received 0 and log(p / (1 - p)) for a received 1. Assume 0 < p < 1.

Hint

At p = 0.5 the observation carries no information, so the LLR is zero.

Test cases

case 1
in: [0,0.1]
expected: 2.1972245773362196
case 2
in: [1,0.1]
expected: -2.197224577336219
case 3
in: [0,0.5]
expected: 0
case 4
in: [1,0.25]
expected: -1.0986122886681098
Starter codePython
import math
def llr_bsc(bit, p):
    # Your code here
    pass

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