Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-131

DPCM Step

Problem

Return the differential pulse-code modulation residual for one sample: the difference between the sample x and its prediction.

Hint

A perfect prediction produces a zero residual.

Test cases

case 1
in: [0.5,0.7]
expected: 0.19999999999999996
case 2
in: [1,1]
expected: 0
case 3
in: [-2,3]
expected: 5
case 4
in: [0,0]
expected: 0
Starter codePython
def dpcm_step(prediction, x):
    # Your code here
    pass

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