title: A fast numpy way to find index in array where cumulative sum becomes greater?
body: <p>Basically, the <em>logic</em> of my problem is:</p>
  
  <pre><code>running_sum = my_array.cumsum()
  greater_than_threshold = running_sum &gt; threshold
  index = greater_than_threshold.searchsorted(True)
  </code></pre>
  
  <p>That is: Find the first index for which the cumulative sum of entries in <code>my_array</code> is above a threshold.</p>
  
  <p>Now the problem is: I know that <code>my_array</code> will be large, but that the condition will be met fairly early. Of course that means I could just do a simple <code>while</code> loop to manually figure out when the cumulative sum is larger than the threshold, but I am wondering if there's a numpythonic way, i.e., a way to test for some condition without having the entire array evaluated.</p>