Skip to content
DeepForgeby svx
All problems
HardTime Seriests-342

AR(2) Stationarity Triangle

Problem

Decide whether an AR(2) process with coefficients phi1 and phi2 is stationary using the stationarity triangle. The three conditions are |phi2| < 1, phi1 + phi2 < 1, and phi2 - phi1 < 1.

Return True only when all three conditions hold.

Hint

The conditions describe a triangle in the (phi1, phi2) plane whose corners are (0, -1), (2, -1), and (0, 1).

Test cases

case 1
in: [0.5,0.25]
expected: true
case 2
in: [1,0.5]
expected: false
case 3
in: [-0.5,0.9]
expected: false
case 4
in: [0,0]
expected: true
case 5
in: [2,-0.5]
expected: false
Starter codePython
def ar2_is_stationary(phi1, phi2):
    # Your code here
    pass

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