kaira.channels.BinaryErasureChannel

Inheritance diagram of BinaryErasureChannel

Inheritance diagram for BinaryErasureChannel

class kaira.channels.BinaryErasureChannel(erasure_prob, erasure_symbol=-1, *args: Any, **kwargs: Any)[source]

Bases: BaseChannel

Binary Erasure Channel (BEC) with symbol erasure probability.

The Binary Erasure Channel is a channel model where bits are either received correctly or erased (lost) with probability p. It’s commonly used to model packet loss in communication systems [MacKay, 2003] [Richardson and Urbanke, 2008].

Mathematical Model:

P(y=e|x=0) = P(y=e|x=1) = p (erasure probability) P(y=0|x=0) = P(y=1|x=1) = 1-p (correct transmission) P(y=1|x=0) = P(y=0|x=1) = 0 (no bit flips)

Parameters:
  • erasure_prob (float) – Probability of bit erasure (0 ≤ p ≤ 1)

  • erasure_symbol (float) – Symbol to use for erasures (default: -1)

Example

>>> channel = BinaryErasureChannel(erasure_prob=0.2)
>>> x = torch.tensor([0, 1, 0, 1], dtype=torch.float32)
>>> y = channel(x)  # Some bits will be replaced with -1 (erasure)

Methods

__init__

Initialize the Binary Erasure Channel.

forward

Apply Binary Erasure Channel errors to the input tensor.

get_config

Get a dictionary of the channel's configuration.

__init__(erasure_prob, erasure_symbol=-1, *args: Any, **kwargs: Any)[source]

Initialize the Binary Erasure Channel.

Parameters:
  • erasure_prob (float) – Probability of bit erasure (0 ≤ p ≤ 1).

  • erasure_symbol (float) – Symbol to use for erasures (default: -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 Erasure 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 erasures.

Return type:

torch.Tensor

get_config() Dict[str, Any]

Get a dictionary of the channel’s configuration.

This method returns a dictionary containing the channel’s parameters, which can be used to recreate the channel instance.

Returns:

Dictionary of parameter names and values

Return type:

Dict[str, Any]