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

Passes the binary input sequence \(x\) through a binary erasure channel (BEC) with erasure probability \(p\).

Parameters:
x: ArrayLike

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

p: float

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

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, e\}\). Erasures \(e\) are represented by -1.

Examples

When 20 bits are passed through a BEC with erasure probability \(p=0.25\), roughly 5 bits are erased 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.bec(x, 0.25); y
Out[2]: 
array([ 0,  1,  1, -1, -1, -1, -1,  1, -1,  1, -1,  0,  0,  1,  0,  0,  0,
        0,  0,  1])

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