背景:
用python画AR模型的时序图。
结果:
代码:
import numpy as np
import matplotlib.pyplot as plt
AR(1)的时序图:x[t]=a*x[t-1]+e
num = 2000
e = np.random.rand(num)
x = np.empty(num)
平稳AR(1)
a = -0.5
x[0] = 2
for i in range(1,num):
x[i] = a*x[i-1]+e[i]
plt.subplot(321,title = AR({0}):x[t]={1}*x[t-1]+e
1