Complete the code to calculate the quantization step size for a given range and number of levels.
step_size = (max_value - min_value) / [1]The quantization step size is the range divided by the number of quantization levels.
Complete the code to quantize a signal value by rounding it to the nearest quantization level.
quantized_value = round((signal_value - min_value) / [1]) * [1] + min_value
We divide by the step size to find the level index, round it, then multiply back by step size to get the quantized value.
Fix the error in the code that calculates the number of quantization levels from the number of bits.
num_levels = 2 [1] num_bits
The number of quantization levels is 2 raised to the power of the number of bits.
Fill both blanks to create a dictionary comprehension that maps signal values to their quantized levels only if the value is above the minimum.
quantized_dict = {value: round((value - min_val) / [1]) * [2] + min_val for value in signal if value > min_val}Both blanks use step_size to scale and reconstruct the quantized value.
Fill all three blanks to create a dictionary comprehension that maps signal values to quantized levels only if the value is less than the maximum and greater than the minimum.
quantized_map = {val: round((val - [1]) / [2]) * [2] + [1] for val in signal if [1] < val < max_val}The minimum value is used to shift the signal, and step size is used for scaling and reconstructing the quantized value.
