komm.BinaryErasureChannel
Binary erasure channel (BEC). It is a discrete memoryless channel with input alphabet $\mathcal{X} = \{ 0, 1 \}$ and output alphabet $\mathcal{Y} = \{ 0, 1, 2 \}$. The channel is characterized by a parameter $\epsilon$, called the erasure probability. With probability $1 - \epsilon$, the output symbol is identical to the input symbol, and with probability $\epsilon$, the output symbol is replaced by an erasure symbol (denoted by $2$). For more details, see CT06, Sec. 7.1.5.
Attributes:
-
erasure_probability
(float
) –The channel erasure probability $\epsilon$. Must satisfy $0 \leq \epsilon \leq 1$. Default value is
0.0
, which corresponds to a noiseless channel.
input_cardinality: int
property
The channel input cardinality $|\mathcal{X}|$.
For the BEC, it is given by $|\mathcal{X}| = 2$.
output_cardinality: int
property
The channel output cardinality $|\mathcal{Y}|$.
For the BEC, it is given by $|\mathcal{Y}| = 3$.
transition_matrix: npt.NDArray[np.floating]
property
The channel transition probability matrix $p_{Y \mid X}$.
For the BEC, it is given by $$ p_{Y \mid X} = \begin{bmatrix} 1 - \epsilon & 0 & \epsilon \\ 0 & 1 - \epsilon & \epsilon \end{bmatrix}. $$
Examples:
>>> bec = komm.BinaryErasureChannel(0.2)
>>> bec.transition_matrix
array([[0.8, 0. , 0.2],
[0. , 0.8, 0.2]])
mutual_information
Returns the mutual information $\mathrm{I}(X ; Y)$ between the input $X$ and the output $Y$ of the channel.
Parameters:
-
input_pmf
(ArrayLike
) –The probability mass function $p_X$ of the channel input $X$. It must be a valid pmf, that is, all of its values must be non-negative and sum up to $1$.
-
base
(LogBase
) –The base of the logarithm to be used. It must be a positive float or the string
'e'
. The default value is2.0
.
Returns:
-
float
–The mutual information $\mathrm{I}(X ; Y)$ between the input $X$ and the output $Y$.
For the BEC, it is given by $$ \mathrm{I}(X ; Y) = (1 - \epsilon) \, \Hb(\pi), $$ in bits, where $\pi = \Pr[X = 1]$, and $\Hb$ is the binary entropy function.
Examples:
>>> bec = komm.BinaryErasureChannel(0.2)
>>> bec.mutual_information([0.45, 0.55])
np.float64(0.7942195631902467)
capacity
Returns the channel capacity $C$.
Parameters:
-
base
(LogBase
) –The base of the logarithm to be used. It must be a positive float or the string
'e'
. The default value is2.0
.
Returns:
-
float
–The channel capacity $C$.
For the BEC, it is given by $$ C = 1 - \epsilon, $$ in bits.
Examples:
>>> bec = komm.BinaryErasureChannel(0.2)
>>> bec.capacity()
np.float64(0.8)
__call__
Transmits the input sequence through the channel and returns the output sequence.
Parameters:
-
input
(ArrayLike
) –The input sequence.
Returns:
-
output
(NDArray[integer]
) –The output sequence.
Examples:
>>> rng = np.random.default_rng(seed=42)
>>> bec = komm.BinaryErasureChannel(0.2, rng=rng)
>>> bec([1, 1, 1, 0, 0, 0, 1, 0, 1, 0])
array([1, 1, 1, 0, 2, 0, 1, 0, 2, 0])