Skip to content

komm.PAModulation

Pulse-amplitude modulation (PAM). It is a real modulation scheme in which the constellation symbols are uniformly arranged in the real line and have zero mean. More precisely, the the $i$-th constellation symbol is given by $$ x_i = A \left( 2i - M + 1 \right), \quad i \in [0 : M), $$ where $M$ is the order (a power of $2$), and $A$ is the base amplitude of the modulation.

Parameters:

  • order (int)

    The order $M$ of the modulation. It must be a power of $2$.

  • base_amplitude (float)

    The base amplitude $A$ of the constellation. The default value is 1.0.

  • labeling (Literal['natural', 'reflected'] | ArrayLike)

    The binary labeling of the modulation. Can be specified either as a 2D-array of integers (see base class for details), or as a string. In the latter case, the string must be either 'natural' or 'reflected'. The default value is 'reflected', corresponding to the Gray labeling.

Examples:

  1. The $4$-PAM modulation with base amplitude $A = 1$ and natural labeling is depicted below.

    4-PAM modulation with Gray labeling.

    >>> pam = komm.PAModulation(4, labeling="natural")
    >>> pam.constellation
    array([-3., -1.,  1.,  3.])
    >>> pam.labeling
    array([[0, 0],
           [0, 1],
           [1, 0],
           [1, 1]])
    
  2. The $8$-PAM modulation with base amplitude $A = 0.5$ and Gray labeling is depicted below.

    8-PAM modulation with Gray labeling.

    >>> pam = komm.PAModulation(8, base_amplitude=0.5)
    >>> pam.constellation
    array([-3.5, -2.5, -1.5, -0.5,  0.5,  1.5,  2.5,  3.5])
    >>> pam.labeling
    array([[0, 0, 0],
           [0, 0, 1],
           [0, 1, 1],
           [0, 1, 0],
           [1, 1, 0],
           [1, 1, 1],
           [1, 0, 1],
           [1, 0, 0]])
    

constellation NDArray[floating] cached property

The constellation $\mathbf{X}$ of the modulation.

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.constellation
array([-3., -1.,  1.,  3.])

labeling NDArray[integer] cached property

The labeling $\mathbf{Q}$ of the modulation.

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.labeling
array([[0, 0],
       [0, 1],
       [1, 1],
       [1, 0]])

inverse_labeling dict[tuple[int, ...], int] cached property

The inverse labeling of the modulation. It is a dictionary that maps each binary tuple to the corresponding constellation index.

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.inverse_labeling
{(0, 0): 0, (0, 1): 1, (1, 1): 2, (1, 0): 3}

order int cached property

The order $M$ of the modulation.

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.order
4

bits_per_symbol int cached property

The number $m$ of bits per symbol of the modulation. It is given by $$ m = \log_2 M, $$ where $M$ is the order of the modulation.

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.bits_per_symbol
2

energy_per_symbol float cached property

The average symbol energy $E_\mathrm{s}$ of the constellation. It assumes equiprobable symbols. It is given by $$ E_\mathrm{s} = \frac{1}{M} \sum_{i \in [0:M)} \lVert x_i \rVert^2, $$ where $\lVert x_i \rVert^2$ is the energy of constellation symbol $x_i$, and $M$ is the order of the modulation.

For the PAM, it is given by $$ E_\mathrm{s} = \frac{A^2}{3}(M^2 - 1). $$

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.energy_per_symbol
5.0

energy_per_bit float cached property

The average bit energy $E_\mathrm{b}$ of the constellation. It assumes equiprobable symbols. It is given by $$ E_\mathrm{b} = \frac{E_\mathrm{s}}{m}, $$ where $E_\mathrm{s}$ is the average symbol energy, and $m$ is the number of bits per symbol of the modulation.

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.energy_per_bit
2.5

symbol_mean float cached property

The mean $\mu_\mathrm{s}$ of the constellation. It assumes equiprobable symbols. It is given by $$ \mu_\mathrm{s} = \frac{1}{M} \sum_{i \in [0:M)} x_i. $$

For the PAM, it is given by $$ \mu_\mathrm{s} = 0. $$

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.symbol_mean
0.0

minimum_distance float cached property

The minimum Euclidean distance $d_\mathrm{min}$ of the constellation. It is given by $$ d_\mathrm{min} = \min_ { i, j \in [0:M), ~ i \neq j } \lVert x_i - x_j \rVert. $$

For the PAM, it is given by $$ d_\mathrm{min} = 2A. $$

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.minimum_distance
2.0

modulate()

Modulates one or more sequences of bits to their corresponding constellation symbols.

Parameters:

  • input (ArrayLike)

    The input sequence(s). Can be either a single sequence whose length is a multiple of $m$, or a multidimensional array where the last dimension is a multiple of $m$.

Returns:

  • output (NDArray[floating])

    The output sequence(s). Has the same shape as the input, with the last dimension divided by $m$.

Examples:

>>> pam = komm.PAModulation(4)
>>> pam.modulate([0, 0, 1, 1, 0, 0, 0, 1])
array([-3.,  1., -3., -1.])

demodulate_hard()

Demodulates one or more sequences of received points to their corresponding sequences of hard bits ($\mathtt{0}$ or $\mathtt{1}$) using hard-decision decoding.

Parameters:

  • input (ArrayLike)

    The input sequence(s). Can be either a single sequence, or a multidimensional array.

Returns:

  • output (NDArray[integer])

    The output sequence(s). Has the same shape as the input, with the last dimension multiplied by $m$.

demodulate_soft()

Demodulates one or more sequences of received points to their corresponding sequences of soft bits (L-values) using soft-decision decoding. The soft bits are the log-likelihood ratios of the bits, where positive values correspond to bit $\mathtt{0}$ and negative values correspond to bit $\mathtt{1}$.

Parameters:

  • input (ArrayLike)

    The received sequence(s). Can be either a single sequence, or a multidimensional array.

  • snr (float)

    The signal-to-noise ratio (SNR) of the channel. It should be a positive real number. The default value is 1.0.

Returns:

  • output (NDArray[floating])

    The output sequence(s). Has the same shape as the input, with the last dimension multiplied by $m$.