komm.ZChannel
Z-channel. It is a discrete memoryless channel with input and output alphabets $\mathcal{X} = \mathcal{Y} = \{ 0, 1 \}$. The channel is characterized by a parameter $p$, called the decay probability. Bit $0$ is always received correctly, but bit $1$ turns into $0$ with probability $p$. Equivalently, the channel can be modeled as $$ Y_n = A_n X_n, $$ where $A_n$ are iid Bernoulli random variables with $\Pr[A_n = 0] = p$.
Attributes:
-
decay_probability
(float
) –The channel decay probability $p$. Must satisfy $0 \leq p \leq 1$. The default value is
0.0
, which corresponds to a noiseless channel.
transition_matrix: npt.NDArray[np.floating]
property
The transition probability matrix of the channel. It is given by $$ p_{Y \mid X} = \begin{bmatrix} 1 & 0 \\ p & 1-p \end{bmatrix}. $$
Examples:
>>> zc = komm.ZChannel(0.2)
>>> zc.transition_matrix
array([[1. , 0. ],
[0.2, 0.8]])
mutual_information
Returns the mutual information $\mathrm{I}(X ; Y)$ between the input $X$ and the output $Y$ of the channel. It is given by $$ \mathrm{I}(X ; Y) = \Hb ( \pi (1-p) ) - \pi \Hb(p), $$ in bits, where $\pi = \Pr[X = 1]$, and $\Hb$ is the binary entropy function.
Parameters:
Same as the corresponding method of the general class.
Examples:
>>> zc = komm.ZChannel(0.2)
>>> zc.mutual_information([0.5, 0.5])
np.float64(0.6099865470109874)
capacity
Returns the channel capacity $C$. It is given by $$ C = \log_2 ( 1 + (1-p) p^{p / (1-p)} ), $$ in bits.
Examples:
>>> zc = komm.ZChannel(0.2)
>>> zc.capacity()
np.float64(0.6182313659549211)
__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)
>>> zc = komm.ZChannel(0.2, rng=rng)
>>> zc([1, 1, 1, 0, 0, 0, 1, 0, 1, 0])
array([1, 1, 1, 0, 0, 0, 1, 0, 0, 0])