class sdr.BinarySymmetricChannel(sdr.Channel)

Implements a binary symmetric channel (BSC).

Notes

The inputs to the BSC are \(x_i \in \mathcal{X} = \{0, 1\}\) and the outputs are \(y_i \in \mathcal{Y} = \{0, 1\}\). The capacity of the BSC is

\[C = 1 - H_b(p) \ \ \text{bits/channel use} .\]

This is an appropriate channel model for binary modulation with hard decisions at the detector.

References

  • John Proakis, Digital Communications, Chapter 6.5-1: Channel Models.

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]: bsc = sdr.BinarySymmetricChannel(0.25, seed=1)

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

In [3]: y = bsc(x); y
Out[3]: array([0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])

In [4]: np.count_nonzero(x != y)
Out[4]: 5

The capacity of this BSC is 0.189 bits/channel use.

In [5]: bsc.capacity
Out[5]: 0.18872187554086717

When the probability \(p\) of bit error is 0, the capacity of the channel is 1 bit/channel use. However, as the probability of bit error approaches 0.5, the capacity of the channel approaches 0.

In [6]: p = np.linspace(0, 1, 101); \
   ...: C = sdr.BinarySymmetricChannel.capacities(p)
   ...: 

In [7]: plt.figure(); \
   ...: plt.plot(p, C); \
   ...: plt.xlabel("Transition probability, $p$"); \
   ...: plt.ylabel("Capacity (bits/channel use), $C$"); \
   ...: plt.title("Capacity of the Binary Symmetric Channel");
   ...: 
../../_images/sdr_BinarySymmetricChannel_1.png

Constructors

BinarySymmetricChannel(p: float, seed: int | None = None)

Creates a new binary symmetric channel (BSC).

Special methods

__call__(x: ArrayLike) NDArray[int_]

Passes the binary input sequence \(x\) through the channel.

Methods

static capacities(p: ArrayLike) NDArray[float64]

Calculates the capacity of BSC channels.

reset(seed: int | None = None)

Resets the channel with a new seed.

Properties

property X : NDArray[np.int_]

The input alphabet \(\mathcal{X} = \{0, 1\}\) of the BSC channel.

property Y : NDArray[np.int_]

The output alphabet \(\mathcal{Y} = \{0, 1\}\) of the BSC channel.

property p : float

The transition probability \(p\) of the BSC channel.

property capacity : float

The capacity \(C\) of the instantiated channel in bits/channel use.