Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Perform Monte Carlo integration using Python programming to estimate the value of . To summarize the approach, consider the unit quarter circle illustrated in the

Perform Monte Carlo integration using Python programming to estimate the value of . To summarize the approach, consider the unit quarter circle illustrated in the figure below:

image text in transcribed

Generate N pairs of uniform random numbers (x,y), where x~ U(0,1) and y ~ U(0,1), and each (x,y) pair represents a point in the unit square. To obtain an estimate of , count the fraction of points that fall inside the unit quarter circle and multiply by 4. Note that the fraction of points that fall inside the quarter circle should tend to the ratio between the area of the unit quarter circle (i.e., ) as compared to area of the unit square (i.e., 1). We proceed step-by-step:

a. Create a function insidecircle that takes two inputs between 0 and 1 and returns 1 if these points fall within the unit circle.

b. Create a function estimatepi that takes a single input N, generates N pairs of uniform random numbers and uses insidecircle to produce an estimate of as described above. In addition to the estimate of , estimatepi should also return the standard error of this estimate, and a 95% confidence interval for the estimate.

c. Use estimatepi to estimate for N = 1000 to 10000 in increments of 500 and record the estimate, its standard error and the upper and lower bounds of the 95% CI. How large must N be in order to ensure that your estimate of is within 0.1 of the true value?

d. Using the value of N you determined in part c), run estimatepi 500 times and collect 500 different estimates of . Produce a histogram of the estimates and note the shape of this distribution. Calculate the standard deviation of the estimates does it match the standard error you obtained in part c)? What percentage of the estimates lies within the 95% CI you obtained in part c)?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

Identify the motives that fuel prejudice.

Answered: 1 week ago