Question: Help is appreciated, please and thank you. Objective: Implement a Monte Carlo method in C++ to estimate the value of . Background: Monte Carlo methods
Help is appreciated, please and thank you.
Objective:
Implement a Monte Carlo method in C++ to estimate the value of .
Background:
Monte Carlo methods repeatedly perform calculations using random numbers to estimate a numerical result. For example, the value of may be estimated by throwing darts randomly at a dartboard.
Consider randomly throwing darts at a square with sides of length 1.0 and a quarter circle inscribed. The probability of a randomly thrown dart hitting inside the quarter circle is equivalent to the area of the circle divided by the area of the square. The area of the quarter circle is /4 and the area of the square 1.0. Therefore, the probability of hitting the quarter circle is /4.

Figure 1 A circle of radius, r=1, inscribed in a square with sides of length, 2.0 and a quarter or the circle inscribed in a square with sides of length, 1.0.
Write an algorithm to throw darts at the small square with the quarter circle and compute the probability of hitting inside the circle. Use the computed probability to estimate . Use a top-down approach to design your program and implement each subtask as a function. Include at least the following functions:
A function called random_double_generator() that takes no arguments and returns a random double between 0 and 1, inclusive.
An overloaded function called random_double_generator(double min, double max) that takes the two arguments, min and max, and returns a random double between min and max, inclusive.
A function called euclidian_distance(double xvalue, double yvalue) that returns the distance for the (x,y) pair provided to the origin.
An overloaded function called euclidian_distance(double x0, double y0, double x1, double y1) that returns the distance between the points (x0,y0) and (x1,y1).
A function called percent_difference(double acceptedValue, double estimatedValue) that returns the absolute value of the percent difference between the two values.
Optional: Repeat this for a unit circle centered at (1,2) using your overloaded functions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
