Question: 6. The Monte Carlo method is an ingenious method for finding approximate solutions to problems that cannot be precisely solved (the method is named after

 6. The Monte Carlo method is an ingenious method for finding

6. The Monte Carlo method is an ingenious method for finding approximate solutions to problems that cannot be precisely solved (the method is named after the famous casino in Monte Carlo) Here is a typical example: It is difficult to compute the number , but you can approximate it quite well with the following simulation. Simulate shooting a dart into a square surrounding a circle of radius 1. That is easy: generate random x and y coordinates between-1 and 1 If the generated point lies inside the circle, we count it as a hit. That is the case when xy s1. Because our shots are entirely random, we expect that the ratio of hits/tries is approximately equal to the ratio of the areas of the circle and the square, that is, /4. Therefore, our estimate for 54 x hits / tries. This method yields an estimate for , using nothing but simple arithmetic. To generate a random floating-point value between -1 and 1, we can use the random) function to generate a random floating-point number r in the range 0 (inclusive) to 1 (exclusive), and then calculate-1 2 * r, which range from-1 (inclusive) to 1 (exclusive). write a Python function that, given the number of tries, produces an estimate for . See how close an approximation to you get after 1,000 tries, after 10,000 tries, after 100,000 tries and after a million tries. Paste your function definition with your test results here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!