kaira.channels.BinaryZChannel

Inheritance diagram for BinaryZChannel
- class kaira.channels.BinaryZChannel(error_prob, *args: Any, **kwargs: Any)[source]
Bases:
BaseChannelZ Channel (asymmetric binary channel) with one-sided error probability.
The Z Channel is an asymmetric binary channel where only one type of bit flip can occur: 1→0 errors happen with probability p, while 0→1 errors never occur. This models systems where one type of error is much more likely than the other [Verdú, 2002] [Golomb, 1980].
- Mathematical Model:
P(y=0|x=1) = p (1→0 error probability) P(y=1|x=1) = 1-p P(y=0|x=0) = 1 (no errors) P(y=1|x=0) = 0
- Parameters:
error_prob (float) – Probability of 1→0 bit flip (0 ≤ p ≤ 1)
Example
>>> channel = BinaryZChannel(error_prob=0.3) >>> x = torch.tensor([0, 1, 0, 1], dtype=torch.float32) >>> y = channel(x) # Some 1s may flip to 0s, but 0s never flip to 1s
Methods
Initialize the Binary Z Channel.
Apply Binary Z Channel errors to the input tensor.
Get a dictionary of the channel's configuration.
- __init__(error_prob, *args: Any, **kwargs: Any)[source]
Initialize the Binary Z Channel.
- Parameters:
error_prob (float) – Probability of 1→0 bit flip (0 ≤ p ≤ 1).
*args – Variable length argument list passed to the base class.
**kwargs – Arbitrary keyword arguments passed to the base class.
- forward(x: Tensor, *args: Any, **kwargs: Any) Tensor[source]
Apply Binary Z Channel errors to the input tensor.
- Parameters:
x (torch.Tensor) – The input tensor (binary 0/1 or bipolar -1/1).
*args – Additional positional arguments (unused).
**kwargs – Additional keyword arguments (unused).
- Returns:
The output tensor with potential 1 -> 0 flips.
- Return type: