title: Scipy expit: Unexpected behavour. NaNs
body: <p>Noticed some <em>nan</em>'s were appearing unexpectedly, in my data.
  (and expanding out and <em>naning</em> everything they touched)
  Did some careful investigation and produced a minimal working example:</p>
  
  <pre><code>&gt;&gt;&gt; import numpy
  &gt;&gt;&gt; from scipy.special import expit
  &gt;&gt;&gt; expit(709)
  1.0
  &gt;&gt;&gt; expit(710)
  nan
  </code></pre>
  
  <p>Expit is the inverse logit. <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.special.expit.html" rel="noreferrer">Scipy documentation here</a>.
  Which tells us: 
  <code>expit(x) = 1/(1+exp(-x))</code></p>
  
  <p>So <code>1+exp(-709)==1.0</code> so that <code>expit(709)=1.0</code> Seems fairly reasonable, rounding <code>exp(-709)==0</code>. <br>
  However, what is going on with <code>expit(710)</code>? <br>
  <code>expit(710)==nan</code> implies that <code>1+exp(-710)==0</code>, which implies: <code>exp(-710)=-1</code> which is not right at all.</p>
  
  <p><strong>What is going on?</strong></p>
  
  <p>I am fixing it with:</p>
  
  <pre><code>def sane_expit(x):
      x = np.minimum(x,700*np.ones_like(x)) #Cap it at 700 to avoid overflow
      return expit(x)
  </code></pre>
  
  <p>But this is going to be a bit slower, because extra op, and the python overhead.</p>
  
  <p>I am using numpy 1.8.-0, and scipy 0.13.2</p>