Saturday, February 8, 2014

The Area of Texas Using the Monte Carlo Method

   In the previous post, the value of Pi was approximated by using the Monte Carlo Method. It might be easy to see that the circle-inscribed-in-a -square method used in the project can be generalized to shapes that are highly irregular, like the shape of Texas.
   As I developed the Area of Texas project, I was surprised to learn that Texas is almost square! The east to west distance is 775 miles and the north to south, 765 miles.
   Here's the image I used in the Scratch project.
   As in the Pi approximation, points are randomly selected in the rectangle. Each point is then tested to determine if it is in Texas.
The sprite used to plot each point is black so the [color black is touching color red] block makes this test a simple one.
  The product of the ratio of points in Texas to the total number of randomly selected points times the area of the rectangle is then the Monte Carlo approximation to the area of Texas.
   Here's a screenshot of the result for selecting 10,000 random points. 
   Google Maps gives the area of Texas as 268,820 square miles. The Scratch script approximated the area as 266,853 square miles.
That's a good approximation to the Google value.
   You can view, use, and download this project from the Scratch website by clicking on this link.
   You can also request a free PDF document containing more detail as to how the script is coded. Send an email request to

No comments:

Post a Comment