title: Python: Interpretation on XCORR
body: <p>I have a question on <a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xcorr" rel="noreferrer">xcorr</a> in Python. Say that I do the following:</p>
  
  <pre><code>output=plt.xcorr(x,y, maxlags=4)
  </code></pre>
  
  <p>Which time-series is lagged? The output will be the cross-correlation between x and y at time <em>t=</em> -4 to +4. So is the output referring to the cross-correlation between x and y as follow?:</p>
  
  <p><img src="https://i.stack.imgur.com/WlZEt.gif" alt="enter image description here">
  or it is the reverse between x and y?
  I tried to dig into the code of xcorr to get a better idea (see <a href="http://matplotlib.sourcearchive.com/documentation/0.98.3/classmatplotlib_1_1axes_1_1Axes_4f32bd673965a088a123e407b46c42fa.html" rel="noreferrer">here</a>) but I am bit lost ... np.correlate(x,y,mode = 2). What does mode = 2 means? I only see <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.correlate.html" rel="noreferrer">here</a> the mode being = <code>valid</code>, <code>full</code>, or <code>same</code>. </p>