Skip to content

komm.UniformQuantizer

Uniform scalar quantizer. It is a scalar quantizer in which the separation between levels is constant, $\Delta$, and the thresholds are the mid-point between adjacent levels.

__init__()

Constructor for the class.

Parameters:

  • num_levels (int)

    The number of quantization levels $L$.

  • input_peak (Optional[float])

    The peak of the input signal $x_\mathrm{p}$. The default value is 1.0.

  • choice (Optional[str])

    The choice for the uniform quantizer. Must be one of 'unsigned' | 'mid-riser' | 'mid-tread'. The default value is 'mid-riser'.

Examples:

>>> quantizer = komm.UniformQuantizer(num_levels=8)
>>> quantizer.levels
array([-0.875, -0.625, -0.375, -0.125,  0.125,  0.375,  0.625,  0.875])
>>> quantizer.thresholds
array([-0.75, -0.5 , -0.25,  0.  ,  0.25,  0.5 ,  0.75])
>>> x = np.linspace(-0.5, 0.5, num=11)
>>> y = quantizer(x)
>>> np.vstack([x, y])
array([[-0.5  , -0.4  , -0.3  , -0.2  , -0.1  ,  0.   ,  0.1  ,  0.2  ,  0.3  ,  0.4  ,  0.5  ],
       [-0.375, -0.375, -0.375, -0.125, -0.125,  0.125,  0.125,  0.125,  0.375,  0.375,  0.625]])
>>> quantizer = komm.UniformQuantizer(num_levels=4, input_peak=1.0, choice='unsigned')
>>> quantizer.levels
array([0.  , 0.25, 0.5 , 0.75])
>>> quantizer.thresholds
array([0.125, 0.375, 0.625])
>>> quantizer = komm.UniformQuantizer(num_levels=4, input_peak=1.0, choice='mid-riser')
>>> quantizer.levels
array([-0.75, -0.25,  0.25,  0.75])
>>> quantizer.thresholds
array([-0.5,  0. ,  0.5])
>>> quantizer = komm.UniformQuantizer(num_levels=4, input_peak=1.0, choice='mid-tread')
>>> quantizer.levels
array([-1. , -0.5,  0. ,  0.5])
>>> quantizer.thresholds
array([-0.75, -0.25,  0.25])

quantization_step property

The quantization step $\Delta$.

input_peak property

The peak of the input signal $x_\mathrm{p}$.

choice property

The choice for the uniform quantizer ('unsigned' | 'mid-riser' | 'mid-tread').