=================== UMSA HW Assignment - Zhang ==================== Calculating pi by Monte Carlo. 1) Write a program to simulate the children's game. Let the circle be centered at the origin, with radius 1. The sides of the square are hence given by x=+/-1 and y=+/-1. You will need a random number generator. Use the one from Prof. Park, or see me (Zhang). 2). Write a program to simulate the grown-up's version of the pi game, as discussed in class. Recall that the idea is to generate points (x,y) uniformly distributed inside the square (see 1) by a Markov random walk process. Start your random walk in an arbitrary position inside the square. In each step, the walker first attempts to move to a new position randomly inside a (smaller) square centered at its current position. Let the sides of this smaller square always be parallel with the x- and y-axes, with lengths 0.8. Then a decision is made on whether to accept the attempted move, which completes one step. Discard the first few hundred steps before starting your measurement (of pi), since the random walk requires some time to equilibrate. Compute pi in 1) and 2), and compare with exact results. Study the accuracy of your results as a function of the number of samples (points). Given an equal number of samples in the measurement, which of the two approaches tends to give the more accurate result? Why? (You may need to run each several times to obtain a statistical measure.) As usual, you are encouraged to work together. Please turn in numerical results, answers to questions, and brief descriptions explaining your programs. Also attach the source codes.