Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-049

Arithmetic Coding Interval Update

Problem

Update an arithmetic coding interval when the next symbol owns the cumulative range [cum_low, cum_high) inside the current interval. Return [low + width * cum_low, low + width * cum_high] where width = high - low.

Hint

Scale the cumulative range by the current interval width.

Test cases

case 1
in: [0,1,0,0.5]
expected: [0,0.5]
case 2
in: [0,1,0.5,1]
expected: [0.5,1]
case 3
in: [0.25,0.75,0.5,0.75]
expected: [0.5,0.625]
case 4
in: [0.1,0.3,0.2,0.9]
expected: [0.14,0.28]
Starter codePython
def arithmetic_update(low, high, cum_low, cum_high):
    # Your code here
    pass

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