All problems
Final Interval Width
Problem
Return the width of the final arithmetic coding interval for a sequence, which is the product of the symbol probabilities: prod(p_i). A long sequence therefore narrows the interval exponentially.
Hint
The interval width equals the probability of the whole sequence.
Test cases
case 1
in: [[0.5,0.5]]
expected: 0.25
case 2
in: [[0.5,0.25,0.25]]
expected: 0.03125
case 3
in: [[1]]
expected: 1
case 4
in: [[0.1,0.2,0.3]]
expected: 0.006000000000000001
Starter codePython
def interval_width(probs):
# Your code here
pass4 test cases · run your code against them in the editor