title: Parallel numerical integration using python
body: <p>I would like to numerically integration a function using multiple cpus in python. I would like to do something like:</p>
  
  <pre><code>from scipy.integrate import quad
  import multiprocessing
  def FanDDW(arguments):
    wtq,eigq_files,DDB_files,EIGR2D_files,FAN_files = arguments
    ...
    return tot_corr
  
  # Numerical integration
  def integration(frequency):
  # Parallelize the work over cpus
    pool = multiprocessing.Pool(processes=nb_cpus)
    total = pool.map(FanDDW, zip(wtq,eigq_files,DDB_files,EIGR2D_files,FAN_files))
    FanDDW_corr = sum(total)
    return quad(FanDDW, -Inf, Inf, args=(zip(wtq,eigq_files,DDB_files,EIGR2D_files,FAN_files)))[0]
  
  vec_functionint = vectorize(integration)
  vec_functionint(3,arange(1.0,4.0,0.5))
  </code></pre>
  
  <p>Also "frequency" is a global variable (external to FanDDW(arguments)). It is a vector containing the position where the function must be evaluated. I guess that quad should choose frequency in a clever way. How to pass it to FanDDW knowing that it should NOT be distributed among CPUs and that pool.map does exactly that (it is the reason why I did put it as a global variable and did not pass it to the definition as argument). </p>
  
  <p>Thank you for any help.</p>
  
  <p>Samuel. </p>