sdr.bsc(x: ArrayLike, p: float, seed: int | None = None) NDArray[int_]

Passes the binary input sequence \(x\) through a binary symmetric channel (BSC) with transition probability \(p\).

Parameters:
x: ArrayLike

The input sequence \(x\) with \(x_i \in \{0, 1\}\).

p: float

The probability \(p\) of a bit flip.

seed: int | None = None

The seed for the random number generator. This is passed to numpy.random.default_rng().

Returns:

The output sequence \(y\) with \(y_i \in \{0, 1\}\).

Examples

When 20 bits are passed through a BSC with transition probability \(p=0.25\), roughly 5 bits are flipped at the output.

In [1]: x = np.random.randint(0, 2, 20); x
Out[1]: array([0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1])

In [2]: y = sdr.bsc(x, 0.25); y
Out[2]: array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1])

In [3]: x == y
Out[3]: 
array([ True, False, False,  True, False,  True,  True,  True,  True,
        True, False,  True,  True,  True,  True,  True, False,  True,
        True,  True])