The Monte Carlo method can be used to estimate the area of an irregular shape. The unknown shape (area) is placed inside a known shape (area). Random points are generated in the known shape (area). Some will fall inside the irregular shape and some will not. Using the counts we can estimate the size (area) of the irregular shape.
The main problem is "how do you count the points inside and outside an irregular shape?" Unless it is automated, counting a large number of random points is a daunting task. Not impossible, just daunting.
Definition: The Monte Carlo method is a mathematical technique that uses a large number of randomly generated numbers to get an approximate solution to a problem that would be difficult to solve by other methods. It is named after the Monte Carlo resort famous for its gambling casino.
In this project we will verify/test the accuracy of the Monte Carlo method.
We will test it using known shapes (areas). They are a circle in a square. A point's distance for the center of the circle can be used to determine if it is inside or outside the circle.
The Monte Carlo method is accurate within certain limits. Test the following number of random points and plot the results (known vs calculated).
There is probably a point of diminishing return as the number of random points increase. (The accuracy growth is not linear?)
Perform each test 10 times and average the results. This will help smooth out the random results. (Do the test 100 times? Draw a bell curve of the test results. Is 100 times better?)
Plot the accuracy of the Monte Carlo method vs the random point counts. Accuracy is the percent difference between the know area and the calculated (estimated) area of the circle. The plot will allow a user to estimate the number of random points to use to get the accuracy they need.
Create two programs. The first program generates the data and save it to a file. The second program read the file and draws the plot.
Assumptions:
Use pyplot or other plot module. For more information about matplotlib.pyplot click HERE .
Do project #1 but with a square inside a square. the inside square's side is one third the outside square's side. (The length of a side of the outside square is 100.)
The inside square represents an unknown shape.
Will using a larger box size compared to the circle inside increase the accuracy?
Experiment with
Run each experiment 1000 times and average the results. Use 10,000 random points for each experiment.
Calculate the mean and standard deviation
Does having the area outside of the circle be approximately the same size of the circle improve accuracy? Is bigger better?
Create a graphics program showing the random points as they are created.
Use graphics.py. For more information click HERE . (download, install, documentation, etc.)
Given a random point inside the square
What do you do if the distance is exactly the radius?
Estimating the area by throwing random points
How to calculate the area of bizarre shapes
The essence of the Monte Carlo method is very simple. If we
allocate points randomly within a square the ratio of the areas of
a circle and a square is equal to the ratio of the number of
points N0
(that fall into a circle) and the total number of points
N1: The larger the area, the more points it gets.
From
How does the Monte Carlo method work? (pdf)