Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Monte Carlo simulation uses random numbers and probability to solve problems. This method has a wide range of applications in computational mathematics, physics, chemistry,

The Monte Carlo simulation uses random numbers and probability to solve problems. This method has a wide range of applications in computational mathematics, physics, chemistry, and finance.

For this project, you are going to generate a circle with a randomly generated sized (the radius), inside of a square, and generate 1,000,000 random (x,y) points. Each (x,y) point should be a float, not integers. For each simulation, you will output the following:

Trial number

Radius of the circle

Computed probability of a (x,y) location inside the circle (Only want 2 decimal places)

Number of hits inside the circle from the simulation

The percentage of hits (Only want 2 decimal places)

An example assuming radius is 1. Probability of a point falling in the circle is circle Area / square Area. In this case, it is ???? / 4. The program generates 1,000,000 points, so the estimated number of hits becomes 1000000 * ???? / 4 = 785398.16 or 78.54 %

Here is a sample output: Trial 1: Radius of the circle is 1 The probability of a point falling in the circle is 78.54 % Simulation resulted in 782123 hits inside the circle or 78.21%

Project Details: Write the program based on the details above and the additional details below.

Since this is a simulation, we will not prompt the user for inputs. To determine the radius of the circle, we are going to implement the Fibonacci series (use modern usage).

Generate a random number from 3 to 20, including 3 and 20.

Use that value to determine the Fibonacci number in the series.

Use the Fibonacci number as your radius for the circle.

Meaning, if the random number is a 5 then you are using the 5th value in the Fibonacci series and use 3 as the radius of the circle.

Once you have the radius, implement the Monte Carlo simulation with 1,000,000 random (x,y) points (remember to make them floats) and display the results of 10 trials using the same radius determined by the Fibonacci number in the series. Each trial does another simulation of 1,000,000 random (x,y).

Display the following for each trial:

Trial number

Radius of the circle

Computed probability of a (x,y) location inside the circle (Only want 2 decimal places)

Number of hits inside the circle from the simulation

The percentage of hits (Only want 2 decimal places)

At the end you have to display the average percentage for all 10 trials.

Bonus Option: Use the last trial and create a graphic representation of the simulation.

Draw a square and corresponding circle (you do not need the grid)

Draw each (x,y) point on the square/circle

Step by Step Solution

3.41 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Note Please maintain proper code spacing indentation just copy the code part and paste it in your co... 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

Statistics The Exploration & Analysis Of Data

Authors: Roxy Peck, Jay L. Devore

7th Edition

0840058012, 978-0840058010

More Books

Students also viewed these Programming questions