Question: Programming Assignment 3 Objective The objective of this assignmenn is to understand the use of theeads and how threads can be used Assignment: Estimating Pi
Programming Assignment 3 Objective The objective of this assignmenn is to understand the use of theeads and how threads can be used Assignment: Estimating Pi () using Monte Carlo Simulations An interesting way of calculating is to use a technique kown as Monte Carlo, which involves randomzatioThis technique works as follows: Suppose you have a circle inscribed ithin a square, as shown in Figure below 0.0) (Assume that the radius of this circle is 1.)Fint, generate a series oftandom points as simple y) coordinates. These points must fall within the Cartesian coordinates that bound the square. Or the total number of random points that are generated, soeme will occur within the circk. Next estimate by performing the following calculation: = 4 x (number of points in circle)/(total number of points) W'rite a multithreaded version of this algoeithm in CC+that creates a separale thread so pencrate a number of random points. The thrcad will count the number of points that occur within the circle and store that result in a global variable. When this thread has exited, the paren thread will calculate and output the estimated value of. It is worth expementing with the mumber of sandom points generated. As a general rule, the greater the number of points, the closer the approximation to . Programming Assignment 3 Objective The objective of this assignmenn is to understand the use of theeads and how threads can be used Assignment: Estimating Pi () using Monte Carlo Simulations An interesting way of calculating is to use a technique kown as Monte Carlo, which involves randomzatioThis technique works as follows: Suppose you have a circle inscribed ithin a square, as shown in Figure below 0.0) (Assume that the radius of this circle is 1.)Fint, generate a series oftandom points as simple y) coordinates. These points must fall within the Cartesian coordinates that bound the square. Or the total number of random points that are generated, soeme will occur within the circk. Next estimate by performing the following calculation: = 4 x (number of points in circle)/(total number of points) W'rite a multithreaded version of this algoeithm in CC+that creates a separale thread so pencrate a number of random points. The thrcad will count the number of points that occur within the circle and store that result in a global variable. When this thread has exited, the paren thread will calculate and output the estimated value of. It is worth expementing with the mumber of sandom points generated. As a general rule, the greater the number of points, the closer the approximation to
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
