title: Python cross correlation
body: <p>I have a pair of 1D arrays (of different lengths) like the following:</p>
  
  <pre><code>data1 = [0,0,0,1,1,1,0,1,0,0,1]
  data2 = [0,1,1,0,1,0,0,1]
  </code></pre>
  
  <p>I would like to get the max cross correlation of the 2 series in python. In matlab, the <code>xcorr()</code> function will return it OK</p>
  
  <p>I have tried the following 2 methods:</p>
  
  <ol>
  <li><code>numpy.correlate(data1, data2)</code></li>
  <li><code>signal.fftconvolve(data2, data1[::-1], mode='full')</code></li>
  </ol>
  
  <p>Both methods give me the same values, but the values I get from python are different from what comes out of matlab. Python gives me integers values > 1, whereas matlab gives actual correlation values between 0 and 1.</p>
  
  <p>I have tried normalizing the 2 arrays first (value-mean/SD), but the cross correlation values I get are in the thousands which doesnt seem correct.</p>
  
  <p>Matlab will also give you a lag value at which the cross correlation is the greatest. I assume it is easy to do this using indices but whats the most appropriate way of doing this if my arrays contain 10's of thousands of values?</p>
  
  <p>I would like to mimic the <code>xcorr(</code>) function that matlab has, any thoughts on how I would do that in python?</p>