kaira.channels.FlatFadingChannel

Inheritance diagram of FlatFadingChannel

Inheritance diagram for FlatFadingChannel

class kaira.channels.FlatFadingChannel(fading_type: str, coherence_time: int, k_factor: float | None = None, avg_noise_power: float | None = None, snr_db: float | None = None, shadow_sigma_db: float | None = None, *args: Any, **kwargs: Any)[source]

Bases: BaseChannel

Flat fading channel with configurable distribution and coherence time.

Models a wireless channel where the fading coefficient remains constant over a specified coherence time and then changes to a new independent realization. This represents blockwise fading commonly used in communications analysis [Tse and Viswanath, 2005] [Rappaport, 2024].

Mathematical Model:

y[i] = h[⌊i/L⌋] * x[i] + n[i] where L is the coherence length, h follows a specified distribution, and n ~ CN(0,σ²)

Parameters:
  • fading_type (str) – Distribution type for fading coefficients (‘rayleigh’, ‘rician’, or ‘lognormal’)

  • coherence_time (int) – Number of samples over which the fading coefficient remains constant

  • k_factor (float, optional) – Rician K-factor (ratio of direct to scattered power), used only when fading_type=’rician’

  • avg_noise_power (float, optional) – The average noise power σ²

  • snr_db (float, optional) – SNR in dB (alternative to avg_noise_power)

  • shadow_sigma_db (float, optional) – Standard deviation in dB for log-normal shadowing, used only when fading_type=’lognormal’

Example

>>> # Create a flat Rayleigh fading channel with coherence time of 10 samples
>>> channel = FlatFadingChannel('rayleigh', coherence_time=10, snr_db=15)
>>> x = torch.complex(torch.ones(100), torch.zeros(100))
>>> y = channel(x)  # Output with block fading effects

Methods

__init__

Initialize the Flat Fading channel.

forward

Apply flat fading and noise to the input signal.

get_config

Get a dictionary of the channel's configuration.

Attributes

k_factor

avg_noise_power

snr_db

shadow_sigma_db

__init__(fading_type: str, coherence_time: int, k_factor: float | None = None, avg_noise_power: float | None = None, snr_db: float | None = None, shadow_sigma_db: float | None = None, *args: Any, **kwargs: Any)[source]

Initialize the Flat Fading channel.

Parameters:
  • fading_type (str) – Distribution type (‘rayleigh’, ‘rician’, ‘lognormal’).

  • coherence_time (int) – Samples over which fading is constant.

  • k_factor (float, optional) – Rician K-factor (for ‘rician’).

  • avg_noise_power (float, optional) – Average noise power σ².

  • snr_db (float, optional) – SNR in dB (alternative to avg_noise_power).

  • shadow_sigma_db (float, optional) – Shadowing std dev in dB (for ‘lognormal’).

  • *args – Variable length argument list passed to the base class.

  • **kwargs – Arbitrary keyword arguments passed to the base class.

k_factor: float | None
shadow_sigma_db: float | None
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]

avg_noise_power: float | None
snr_db: float | None
forward(x: Tensor, *args: Any, csi=None, noise=None, **kwargs: Any) Tensor[source]

Apply flat fading and noise to the input signal.

Parameters:
  • x (torch.Tensor) – The input tensor.

  • *args – Additional positional arguments (unused).

  • csi (Optional[torch.Tensor]) – Pre-computed channel state information (fading coefficients). If provided, these coefficients are used instead of generating new ones.

  • noise (Optional[torch.Tensor]) – Pre-generated noise tensor. If provided, this noise is added.

  • **kwargs – Additional keyword arguments (unused).

Returns:

The output tensor after applying fading and noise.

Return type:

torch.Tensor