Question: Write a C++ program that uses a Monte Carlo method to determine experimentally the expected distance of a randomly selected point in the unit disk
Write a C++ program that uses a Monte Carlo method to determine experimentally the expected distance of a randomly selected point in the unit disk from a given point (a, b). To simulate this, we will draw N points (x1, y1), . . . ,(xN , yN ) from the unit disk, uniformly at random. For each point, compute the distance of the point to (a, b). The average of the distances of the selected points to (a, b) is an approximation of the expected distance of a randomly selected point in the unit disk to (a, b). The program should take three command line arguments: A double for the coordinate a, a double for the coordinate b, and an integer N representing the number of trials. The exact average distance of a point selected uniformly at random from the disk to the origin (0, 0) is 2/3 . The approximate average distance of a point selected uniformly at random from the disk to the point (1, 0) is 1.1318.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
