我要计算很多对序列的互相关。事实上,我只关心前100个滞后
这是我的代码和一些编造的数据:
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.tsa.stattools as stattools
def create(n):
x = np.zeros(n)
for i in range(1, n):
if np.random.rand() < 0.9:
if np.random.rand() < 0.5:
x[i] = x[i-1] + 1
else:
x[i] = np.random.randint(0,100)
return x
x = create(4000)
y = create(4000)
plt.plot(stattools.ccf(x, y)[:100])
如果我这样做了
%timeit stattools.ccf(x, y)[:100]
我明白了
100 loops, best of 3: 10.7 ms per loop
有没有可能再快一点
目前没有回答
相关问题 更多 >
编程相关推荐