title: Random Walk - Parallel processing
body: <p>I'm currently implementing a monte-carlo method to solve a diffusion equation. The solution can be expressed as a mathematical expectation of phi(W) where phi is a function (varies accordingly to the diffusion equation) and W is a symmetric random walk stopped at the boundary of the domain. To evaluate the function at a point x, I need to start every walk in the expectation from x. </p>
  
  <p>I want to evaluate the function at a large number of points. So this is what I do:</p>
  
  <ol>
  <li>I start simultaneously one walk from every point</li>
  <li>I use the same steps for every point</li>
  <li>Once each walk has reached the boundary, I stop </li>
  <li>I repeat these operations N times, in order to approximate the mathematical expectation by the frequency over N simulations.</li>
  </ol>
  
  <p>My code (Python) looks like this :</p>
  
  <pre><code>for k in range(N): #For each "walk"
      step = 0
      while not(every walk has reach the boundary):
          map(update_walk,points) #update the walk starting from each x in points
          incr(step)
  </code></pre>
  
  <p>The problem is : it is extremely long since N can be large and the number of points also. I am looking for ANY solution that will help me optimize this code.</p>
  
  <p>I have thought of parallel processing (each walk is independent) with IPython but I did not succeed because it is inside a function (it returned an error like </p>
  
  <blockquote>
    <p>"could not launch function 'f' because it was not found as 'file.f' " but 'f' is define within file.big_f)</p>
  </blockquote>