title: Python - speed up finding percentile of set which is greater than threshold
body: <p>I need to find which percentile of a group of numbers is over a threshold value. Is there a way that this can be speed up? My implementation is much too slow for the intended application. In case this changes anything, I am running my program using <code>mpirun -np 100 python program.py</code>. I cannot use numba, as the rest of this program uses try/except statements.</p>
  
  <pre><code>import numpy as np
  my_vals = []
  threshold_val = 0.065
  for i in range(60000):
      my_vals.append(np.random.normal(0.05, 0.02))
  
  for i in np.arange(0,100,0.001):
      if np.percentile(my_vals,i) &gt; threshold_val:
          perc = 1*i
          break
  else: perc = 100
  </code></pre>