title: Is there a numpy builtin to reject outliers from a list
body: <p>Is there a numpy builtin to do something like the following? That is, take a list <code>d</code> and return a list <code>filtered_d</code> with any outlying elements removed based on some assumed distribution of the points in <code>d</code>.</p>
  
  <pre><code>import numpy as np
  
  def reject_outliers(data):
      m = 2
      u = np.mean(data)
      s = np.std(data)
      filtered = [e for e in data if (u - 2 * s &lt; e &lt; u + 2 * s)]
      return filtered
  
  &gt;&gt;&gt; d = [2,4,5,1,6,5,40]
  &gt;&gt;&gt; filtered_d = reject_outliers(d)
  &gt;&gt;&gt; print filtered_d
  [2,4,5,1,6,5]
  </code></pre>
  
  <p>I say 'something like' because the function might allow for varying distributions (poisson, gaussian, etc.) and varying outlier thresholds within those distributions (like the <code>m</code> I've used here).</p>