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

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

View Full Document Right Arrow Icon
3/15/2016 [1/4] Monte Carlo Area of Illinois - Homework 2 - RELATE https://relate.cs.illinois.edu/course/cs357-sp16/flow-session/84748/0/ 1/1 Monte Carlo Area of Illinois Computing the area of objects that are odd shapes can be quite difficult. 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.
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern