In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [17]:
e = (np.random.rand(100) - 0.5) * 3.
x = 2.*np.cos(np.linspace(0, 10, e.shape[0]))
y = 1.3*x+e
y_ar = [0]
for e_i, x_i in zip(e, x):
y_ar += [1.3*x_i + 0.3 * y_ar[-1] + e_i]
y_ar = np.array(y_ar[1:])
y_ma = []
e_i_minus_1 = 0
for e_i, x_i in zip(e, x):
y_ma += [1.3*x_i+e_i+0.2*e_i_minus_1]
e_i_minus_1 = e_i
y_ma = np.array(y_ma)
plt.plot(x)
plt.plot(y)
plt.plot(y_ar)
plt.plot(y_ma)
Out[17]:
In [29]:
e = np.random.laplace(0, 2., 100)
y = e
y_ma = e + 0.7*np.r_[0., e[:-1]]
plt.plot(y)
plt.plot(y_ma)
Out[29]:
In [25]:
np.arange(10)[:-1]
Out[25]:
In [ ]: