Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-128

Dither Variance

Problem

Return the variance of uniform dither distributed on [-step/2, step/2]:

var = step^2 / 12

Hint

This matches the quantization error variance of a uniform quantizer.

Test cases

case 1
in: [1]
expected: 0.08333333333333333
case 2
in: [2]
expected: 0.3333333333333333
case 3
in: [0.5]
expected: 0.020833333333333332
case 4
in: [6]
expected: 3
Starter codePython
def dither_variance(step):
    # Your code here
    pass

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