pydsm.simulation.ds_quantize¶
- pydsm.simulation.ds_quantize(y, n)¶
Quantize a signal according to a given number of levels.
Parameters: y : real or array of reals
signal to be quantized (1 sample!). A column vector with more than 1 row if there are multiple quantizers.
n : int or vector of ints
number of quantization levels. Can be a vector to specify multiple quantizers, in this case, y must have as many rows as the entries in n
Returns: z : real or ndarray
quantized signal (1 sample!). A column vector with more than 1 row if there are multiple quantizers.
Notes
y is quantized to:
- an odd integer in [-n+1, n-1], if n is even, or
- an even integer in [-n, n], if n is odd.
This definition gives the same step height for both mid-riser and mid-tread quantizers.