# hw2 - [1/4 Monte Carlo Area of Illinois Homework 2 RELATE...

• Homework Help
• 6

This preview shows pages 1–2. Sign up to view the full content.

3/15/2016 [1/4] Monte Carlo Area of Illinois - Homework 2 - RELATE 1/1 Monte Carlo Area of Illinois Computing the area of objects that are odd shapes can be quite diﬃcult. However, Monte Carlo simulation can be used to easily find the areas of objects that are odd shapes. This problem will focus on using Monte Carlo simulation to compute the area of an object that is an odd shape, specifically the state of Illinois. Consider the picture [illinois_bw.png] . This picture is adapted from one on Wikimedia . Write Python code that uses Monte Carlo simulation with this picture to estimate the area of the state of Illinois. Pixels in the picture that are black are inside of Illinois and pixels in the picture that are white are outside of Illinois. The entire picture is 540 pixels wide by 800 pixels tall. This corresponds to physical distance of 304 miles wide by 450 miles tall. Your code will see a variable called img which is a numpy array containing the image data. The image is black and white -- the entries in img are either 0 or 1. If you wish to program this on your local machine, you will want to download the image and use mpimg.imread(fname) , where fname is a string of the file name. Note, you do not need to (and can't) do that when submitting your code here. When submitting your code here, you should use the variable img which is already a numpy array with the image data.

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern