kaira.channels.BinarySymmetricChannel

Inheritance diagram for BinarySymmetricChannel
- class kaira.channels.BinarySymmetricChannel(crossover_prob, *args: Any, **kwargs: Any)[source]
Bases:
BaseChannelBinary Symmetric Channel (BSC) with symmetric bit flip probability.
The Binary Symmetric Channel is a fundamental model in information theory where each bit is independently flipped with probability p. It represents a binary channel with symmetric crossover characteristics [Cover and Thomas, 2006].
- Mathematical Model:
P(y=0|x=1) = P(y=1|x=0) = p (crossover probability) P(y=0|x=0) = P(y=1|x=1) = 1-p
- Parameters:
crossover_prob (float) – Probability of bit flip (0 ≤ p ≤ 0.5)
Example
>>> channel = BinarySymmetricChannel(crossover_prob=0.1) >>> x = torch.tensor([0, 1, 0, 1], dtype=torch.float32) >>> y = channel(x) # Some bits will be flipped with 10% probability
Methods
Initialize the Binary Symmetric Channel.
Apply Binary Symmetric Channel errors to the input tensor.
Get a dictionary of the channel's configuration.
- __init__(crossover_prob, *args: Any, **kwargs: Any)[source]
Initialize the Binary Symmetric Channel.
- Parameters:
crossover_prob (float) – Probability of bit flip (0 ≤ p ≤ 0.5).
*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 Symmetric 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 bit flips.
- Return type: