title: Python OverflowError: math range error being raised differently in different runs
body: <p>My program seems to be crashing almost arbitrarily.</p>
  
  <p>My code includes these two lines:</p>
  
  <pre><code>z[i, j] = -math.exp(oneminusbeta[j, i])
  weights[i,j] = math.exp(beta[j,i] + oneminusbeta[j,i])
  </code></pre>
  
  <p>I've run my whole code before on data that had 2 dimensions, it was <code>7341 x 648</code>. I had no issues at all running that code.</p>
  
  <p>But now the data I'm using is about ten times as big. It's <code>71678 x 648</code>, and I'm getting this error:</p>
  
  <pre><code>OverflowError: math range error
  </code></pre>
  
  <p>And I'm not getting this on any specific point. I'm logging comments before every line of code so that I can see what's causing the crash, and it appears the crash is happening more often on the second line mentioned above (<code>weights[i,j] = math.exp(beta[j,i] + oneminusbeta[j,i])</code>).</p>
  
  <p>The thing is, it crashes at different times.
  At first, it crashed at <code>weights[30816, 42]</code>. Then at <code>weights[55399, 43]</code>. Then at <code>z[33715,45]</code>. But the data is the same in all 3 cases.</p>
  
  <p>What could the problem be? Is this a memory related issue with python? I'm using <code>Numba</code> too, by the way.</p>
  
  <h2>Edit</h2>
  
  <p>I forgot to mention, I've put thresholds so that what goes into the <code>exp()</code> function doesn't exceed what 709 or -708, so technically there shouldn't be an overflow.</p>