Monte Carlo Integration - Parallel Easier Than Sequential


A typical problem when introducing Monte Carlo Techniques is calculating the area of some two dimensional figure which lies inside another object whose size is known. The figure you see above is enclosed by a square of unit area and you start picking random points which lie in this square. All you have to do is count the total number of points you picked and how many were inside the figure. The area you are looking for is then just the ratio of the points inside the figure to the total number of points. (You have to multiply this by the area of the bounding box if it is not one.)
The borders of our figure are actually simple analytic funtions in every quadrant,

quadrant1upper rightcircle with radius 0.5, center at (0.5, 0.5)y=-sqrt(-x*x+x)+0.5
quadrant2lower rightquadraticy=1.2*x*x-0.3
quadrant3lower leftellipsey=-sqrt((1-x*x/0.25)*0.09)
quadrant4upper leftcircle with radius 0.5, center at (0,0)y=sqrt(0.25-x*x)

If you write a sequential program to find the area of this figure you might do something like,

A more parallel approach would be,
This would determine the size of the part of the figure which lies in the first quadrant and it is simple enough to then move on to the second quadrant and so on. We will use this concept for our parallel program but we are going to use four different slave programs, one for each quadrant.

Previous: The Bifurcation Map - Made To Be Parallized
Next: The Master, it's getting a little bit more complicated
Index: Getting started with PVM