All problems
Adaptive Quantization Step
Problem
Choose the uniform quantization step that achieves a target SNR for a signal with the given variance. With target SNR_linear = 10^(target_snr_db / 10) and mean squared error step^2 / 12, solve for the step:
step = sqrt(12 * signal_var / SNR_linear)
Hint
Louder signals or lower targets allow coarser steps.
Test cases
case 1
in: [1,0]
expected: 3.4641016151377544
case 2
in: [1,10]
expected: 1.0954451150103321
case 3
in: [4,20]
expected: 0.6928203230275509
case 4
in: [9,6.02]
expected: 5.196511320715222
Starter codePython
import math
def adaptive_quant_step(signal_var, target_snr_db):
# Your code here
pass4 test cases · run your code against them in the editor