In Monte Carlo integration, we choose random numbers to integrate over a certain range. An example we will simulate in this assignment
is finding the area of a circle. Random numbers will be generated to integrate the area of a circle at the origin with radius r = 1.
For every number generated that fits in the circle, it will be count as a "hit" and numbers that go outside the area will be a "miss."
Below is an example graph of an integrated circle using Monte Carlo integration:
Figure 1: Monte Carlo integration of a circle centered at origin with radius 1, iterated 3000 times
The red plots in the graph are random points generated that fit in this circle's radius and the green points are random points generated outside of the area. By accomplishing this in two dimensions, we can try and integrate a sphere in three dimensions. Then, we can also work with multi-dimension spheres called hyperspheres.
C++ Source files: Circle integration, sphere integration, hypersphere integration.
The drand48() function in the source codes generates random numbers for x and y values between [-1,1]. For the three dimensional sphere, the z values are included. In the hypersphere code, a nested for loop is used to generate values based on the number of dimensions entered in the program.
Now that we know how a circle is integrated, let's take a look at a sphere in three dimensions:
Figure 2: Sphere centered at origin with radius 1, repeated at 1000 trials
Figure 3: Sphere centered at origin with radius 1, repeated at 30 000 trials
Actual volume: 4.18879
Fractional error: 0.11679
Actual volume: 4.1887
Fractional error: 0.0183902
Figure 4: Fractional error vs trials for a 2D circle
Figure 5: Fractional error bv trials for a 3D sphere
From this assignment, we see that Monte Carlo Integration is possible with multidimensional spheres. We can probably use this same method to integrate more complex figures in multiple dimensions, such as a cube. The issue with accuracy is that more trials are needed as the dimensions increase, but sometimes that may be hard to compute because the program may not be able to allocate enough memory for large numbers. It will also take a while for the computer to finish processing the loops. I also noticed that as the dimensions increase, the volume of the hyperspheres decrease. Even though we only tested up to 10 dimensions, it's possible that the volume will keep decreasing and get close to zero.
 PHYS 305 Assignment #6. Varner, Gary
 N-Dimensions. http://thinkzone.wlonk.com/MathFun/Dimens.htm
 Hypersphere http://mathworld.wolfram.com/Hypersphere.html