Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-074

Uniform Quantizer Distortion

Problem

Return the mean squared error of a uniform quantizer with n levels for a source uniform on [-a, a]. With step size delta = 2a / n and uniform quantization error,

MSE = delta^2 / 12 = a^2 / (3 * n^2)

Hint

Doubling the number of levels reduces the step size by half and the MSE by four.

Test cases

case 1
in: [1,2]
expected: 0.08333333333333333
case 2
in: [3,4]
expected: 0.1875
case 3
in: [2,8]
expected: 0.020833333333333332
case 4
in: [1,1]
expected: 0.3333333333333333
Starter codePython
def uniform_quantizer_mse(a, n):
    # Your code here
    pass

4 test cases · run your code against them in the editor