All problems
Levinson-Durbin Coefficients
Problem
Run the Levinson-Durbin recursion to order 2 from an autocovariance list [r0, r1, r2]. With k1 = r1 / r0 and v1 = r0 * (1 - k1^2), set k2 = (r2 - k1 * r1) / v1 (0.0 if v1 is 0), then return [a1, a2, v2] where a1 = k1 * (1 - k2), a2 = k2, and v2 = v1 * (1 - k2^2).
If r0 is 0 return [0.0, 0.0, 0.0].
Hint
v2 is the order-2 prediction error variance and shrinks as k2 grows.
Test cases
case 1
in: [[1,0.5,0.25]]
expected: [0.5,0,0.75]
case 2
in: [[1,0.6,0.3]]
expected: [0.65625,-0.09375,0.634375]
case 3
in: [[2,1,0.5]]
expected: [0.5,0,1.5]
case 4
in: [[1,0,0]]
expected: [0,0,1]
Starter codePython
def levinson_durbin(acf):
# Your code here
pass4 test cases · run your code against them in the editor