Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compute by a Monte Carlo Method 3 points Monte Carlo methods are any numerical methods determined by the use of random numbers in processes-like radioactive

image text in transcribed

Compute by a Monte Carlo Method 3 points Monte Carlo methods are any numerical methods determined by the use of random numbers in processes-like radioactive decay of a particle or the likelihood of a single molecule to react (Note that the physical processes aren't called "Monte Carlo", only the numerical methods using random numbers.) We will use a random method, called Buffon's Needle. to estimate the value of . Consider a circle inscribed inside of a square. If the circle has unit radius, r-1, then its area A = r2-T. The square in which it is inscribed has vertices (-1,-1), (+1,-1). (+1, +1), (-1, +1) with area A = 2 2 = 4. If you consider throwing a dart at the square, the probability that it lands inside of the circle is We can thus use nade as a proxy for Acircle and treat the square similary As are Compose a function mc-pi( n ) to estimate the value of using the Buffon's Needle method, n describes the number of points to be used in the simulation. mc_pi should return its estimate of the value of as a float . Your process should look like the following 1. Prepare an array of coordinate pairs xy. This should be of shape n,2) selected from an appropriate distribution (see notes 1 and 2 below) 2 Calculate the number of coordinate pairs inside the circle's radius. (How would you do this mathematically? Can you do this in NumPy without a loop?-although a loop is okay.) 3. Calculate the ratio eiAcirele 4. Return this estimate of 5. You may find it edifying to try the following values of n , and compare each result to the value of math. pi : 10 1 , 1ee. 1e4 1e5 , 1e6, 1e7 1e8. How does the tcirclo which implies (following the development above), 4 nsquare Asquare computational time vary? How about the accuracy of the estimate of ? You will need to consider the following notes 1. Which kind of distribution is most appropriate for randomly sampling the entire area? (Hint: if we could aim, it would be the normal distribution-but we shouldn't aim in this 2 Since numpy.random distributions accept sizes as arguments, you could use something like np.random.distribution( n,2 to generate coordinate pairs (in the range [0,1) which you'll then need to transform)-but use the right distribution! Given a distribution from [0, 1), how would you transform it to encompass the range-1,1)? (You can do this to the entire array at once since addition and multiplication are vectorized operations.) Your submission should include a function mc_pin) (This assignment is based on Langtangen, Exercise 8.29.) Compute by a Monte Carlo Method 3 points Monte Carlo methods are any numerical methods determined by the use of random numbers in processes-like radioactive decay of a particle or the likelihood of a single molecule to react (Note that the physical processes aren't called "Monte Carlo", only the numerical methods using random numbers.) We will use a random method, called Buffon's Needle. to estimate the value of . Consider a circle inscribed inside of a square. If the circle has unit radius, r-1, then its area A = r2-T. The square in which it is inscribed has vertices (-1,-1), (+1,-1). (+1, +1), (-1, +1) with area A = 2 2 = 4. If you consider throwing a dart at the square, the probability that it lands inside of the circle is We can thus use nade as a proxy for Acircle and treat the square similary As are Compose a function mc-pi( n ) to estimate the value of using the Buffon's Needle method, n describes the number of points to be used in the simulation. mc_pi should return its estimate of the value of as a float . Your process should look like the following 1. Prepare an array of coordinate pairs xy. This should be of shape n,2) selected from an appropriate distribution (see notes 1 and 2 below) 2 Calculate the number of coordinate pairs inside the circle's radius. (How would you do this mathematically? Can you do this in NumPy without a loop?-although a loop is okay.) 3. Calculate the ratio eiAcirele 4. Return this estimate of 5. You may find it edifying to try the following values of n , and compare each result to the value of math. pi : 10 1 , 1ee. 1e4 1e5 , 1e6, 1e7 1e8. How does the tcirclo which implies (following the development above), 4 nsquare Asquare computational time vary? How about the accuracy of the estimate of ? You will need to consider the following notes 1. Which kind of distribution is most appropriate for randomly sampling the entire area? (Hint: if we could aim, it would be the normal distribution-but we shouldn't aim in this 2 Since numpy.random distributions accept sizes as arguments, you could use something like np.random.distribution( n,2 to generate coordinate pairs (in the range [0,1) which you'll then need to transform)-but use the right distribution! Given a distribution from [0, 1), how would you transform it to encompass the range-1,1)? (You can do this to the entire array at once since addition and multiplication are vectorized operations.) Your submission should include a function mc_pin) (This assignment is based on Langtangen, Exercise 8.29.)

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

Step: 3

blur-text-image

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 And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

When should the last word in a title be capitalized?

Answered: 1 week ago

Question

LO2 Explain the nature of the psychological contract.

Answered: 1 week ago

Question

LO1 Discuss four different views of motivation at work.

Answered: 1 week ago