title: Infinite Summation in Python
body: <p>I have a function for with i need to do an infinite summation on (over all the integers) numerically. The summation doesn't always need to converge as I can change internal parameters. The function looks like,</p>
  
  <pre><code>m(g, x, q0) = sum(abs(g(x - n*q0))^2 for n in Integers)
  m(g, q0) = minimize(m(g, x, q0) for x in [0, q0])
  </code></pre>
  
  <p>using a Pythonic pseudo-code</p>
  
  <p>Using Scipy integration methods, I was just flooring the n and integrating like for a fixed x,</p>
  
  <pre><code>m(g, z, q0) = integrate.quad(lambda n:
                               abs(g(x - int(n)*q0))**2,
                               -inf, +inf)[0]
  </code></pre>
  
  <p>This works pretty well, but then I have to do optimization on the x as a function of x, and then do another summation on that which yields a integral of a optimization of an integral. Pretty much it takes a really long time.</p>
  
  <p>Do you know of a better way to do the summation that is faster? Hand coding it seemed to go slower.</p>
  
  <p>Currently, I am working with</p>
  
  <pre><code>g(x) = (2/sqrt(3))*pi**(-0.25)*(1 - x**2)*exp(-x**2/2)
  </code></pre>
  
  <p>but the solution should be general</p>
  
  <p>The paper this comes from is "The Wavelet Transform, Time-Frequency Localization and Signal Analysis" by Daubechies (IEEE 1990)</p>
  
  <p>Thank you</p>