title: How do I compare two arrays element-wise in Python using specific rules?
body: <p>Let's say I have:</p>
  
  <pre><code>numpy.random.seed(20)
  a=numpy.random.rand(5000)
  b=numpy.random.rand(5000)
  </code></pre>
  
  <p>I want to get the indices of a where <code>a[x] &gt; b[x]</code>, i.e. all x's</p>
  
  <p>Furthermore, I want to get the indices of a where <code>(a[x-1] &lt; b[x-1]) &amp;&amp; (a[x] &gt; b[x])</code>.</p>
  
  <p>Can someone please help?  I've got a feeling I have to use masked arrays, but I can't quite figure out how.</p>