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. For more details, see Say06, Sec. 9.4.

Attributes:

  • num_levels (int)

    The number of quantization levels $L$. It must be greater than $1$.

  • input_range (tuple[float, float])

    The range $(x_\mathrm{min}, x_\mathrm{max})$ of the input signal. The default is $(-1.0, 1.0)$.

  • choice (Literal['mid-riser', 'mid-tread'])

    The choice for the uniform quantizer. Must be either 'mid-riser' or 'mid-tread'. The default is 'mid-riser'.

Examples:

>>> quantizer = komm.UniformQuantizer(num_levels=4, input_range=(-1.0, 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_range=(-1.0, 1.0), choice='mid-tread')
>>> quantizer.levels
array([-1. , -0.5,  0. ,  0.5])
>>> quantizer.thresholds
array([-0.75, -0.25,  0.25])
>>> quantizer = komm.UniformQuantizer(num_levels=4, input_range=(0.0, 1.0), choice='mid-tread')
>>> quantizer.levels
array([0.  , 0.25, 0.5 , 0.75])
>>> quantizer.thresholds
array([0.125, 0.375, 0.625])

quantization_step: float cached property

The quantization step $\Delta$.

levels: npt.NDArray[np.float64] cached property

The quantizer levels $v_0, v_1, \ldots, v_{L-1}$.

thresholds: npt.NDArray[np.float64] cached property

The quantizer finite thresholds $t_1, t_2, \ldots, t_{L-1}$.