交叉和自动关联演示

使用互相关(xcorr)和自相关(acorr)图的示例。

交叉和自动关联演示图例

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. # Fixing random state for reproducibility
  4. np.random.seed(19680801)
  5. x, y = np.random.randn(2, 100)
  6. fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)
  7. ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
  8. ax1.grid(True)
  9. ax1.axhline(0, color='black', lw=2)
  10. ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
  11. ax2.grid(True)
  12. ax2.axhline(0, color='black', lw=2)
  13. plt.show()

下载这个示例