擅长:python、mysql、java
<p>你要做的是这两个信号的<a href="https://en.wikipedia.org/wiki/Cross-correlation" rel="nofollow noreferrer">cross-correlation</a>。在</p>
<p>使用<code>scipy</code>库中的<a href="http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.signal.correlate.html" rel="nofollow noreferrer">^{<cd1>}</a>可以轻松完成此操作:</p>
<pre><code>import scipy.signal
import numpy as np
# limit your signal length to speed things up
lim = 25000
# do the actual correlation
corr = scipy.signal.correlate(y[:lim], y2[:lim], mode='full')
# The offset is the maximum of your correlation array,
# itself being offset by (lim - 1):
offset = np.argmax(corr) - (lim - 1)
</code></pre>
<p>您可能想看看类似问题的<a href="https://stackoverflow.com/a/4690225/1525423">this</a>答案。在</p>