import numpy as np
import matplotlib.pyplot as plt
A = np.array([[0.6, -0.8],[ 0.7, 0.6]])
eval, evec = np.linalg.eig(A)
print(eval)
print(abs(eval))
[0.6+0.74833148j 0.6-0.74833148j] [0.9591663 0.9591663]
Sx = np.eye(2)*1600
Sw = np.eye(2)
Sx11 = []
for i in range(100):
Sx = A@Sx@A.T + Sw
Sx11.append(Sx[0,0])
print(Sx)
plt.figure(figsize=(8,4), dpi=100)
plt.plot(Sx11)
plt.show()
[[13.7888224 -0.02868337] [-0.02868337 12.08430949]]
x = 40*np.random.randn(2)
x_hist = []
for t in range(400):
x = A.dot(x) + np.random.randn(2)
x_hist.append(x)
plt.figure(figsize=(8,4), dpi=100)
plt.plot(x_hist)
plt.show()
x_ss = np.array(x_hist).T[:,200:]
print(np.cov(x_ss))
[[12.43797211 -0.18757096] [-0.18757096 10.46040716]]