Question: 3. (Integral Estimation using Monte Carlo Simulation) (40 points) One application of Monte Carlo Simulation is estimating a difficult to evaluate integral. In this ques-

 3. (Integral Estimation using Monte Carlo Simulation) (40 points) One application

3. (Integral Estimation using Monte Carlo Simulation) (40 points) One application of Monte Carlo Simulation is estimating a difficult to evaluate integral. In this ques- tion, we will perform a simple simulation to estimate the area of a unit circle. (a) (10 points) Generate 10,000 points uniformly distributed in [-1.1) and plot a histogram of these points using 50 uniform-sized bins. Hint: See the histogram function in matplotlib; in particular, if your data is stored in an array X, then you can use matplotlib.hist(X,bins = 50, normed =True). (b) (15 points) Generate 10.000 points that are uniformly distributed in a square around the origin with corners (-1,-1),(-1,1),(1, -1) and (1,1). To do this, independently generate the r and y-coordinates of a point to be uniformly distributed in (-1,1). Create an additional array Z of length 10.000, which indicates whether each random point lies within a circle of radius 1 centered at the origin. Plot these points using a scatter plot with different colors for points within the circle and points outside. Hint: If you store your coordinate vectors as X and Y and the vector of indicators as Z, then use plt.scatter(X,Y, C = Z, s = 2.0, cmap=plt.cm. Paired). (c) (15 points) Given n random points as above, we can estimate was in = 4Ncircle, where Neirde is the number of random points which lie within the circle. For n between 1 and 1000, plot the relative error - #/t. Also plot the function 1/v on the same plot. How do the relative errors compare to this function? (d) (OPTIONAL) Above we used simulation to compute the area of a unit circle. Using a similar process, we can find the volume of a 'sphere' in n dimensions. Estimate this volume for dimensions de {2,3,..., 20), using 100,000 samples in each dimension. How does your estimate of the volume of the sphere behave as the dimension increases? Also, do your estimates seem smooth or noisy (and if the latter, why)? 3. (Integral Estimation using Monte Carlo Simulation) (40 points) One application of Monte Carlo Simulation is estimating a difficult to evaluate integral. In this ques- tion, we will perform a simple simulation to estimate the area of a unit circle. (a) (10 points) Generate 10,000 points uniformly distributed in [-1.1) and plot a histogram of these points using 50 uniform-sized bins. Hint: See the histogram function in matplotlib; in particular, if your data is stored in an array X, then you can use matplotlib.hist(X,bins = 50, normed =True). (b) (15 points) Generate 10.000 points that are uniformly distributed in a square around the origin with corners (-1,-1),(-1,1),(1, -1) and (1,1). To do this, independently generate the r and y-coordinates of a point to be uniformly distributed in (-1,1). Create an additional array Z of length 10.000, which indicates whether each random point lies within a circle of radius 1 centered at the origin. Plot these points using a scatter plot with different colors for points within the circle and points outside. Hint: If you store your coordinate vectors as X and Y and the vector of indicators as Z, then use plt.scatter(X,Y, C = Z, s = 2.0, cmap=plt.cm. Paired). (c) (15 points) Given n random points as above, we can estimate was in = 4Ncircle, where Neirde is the number of random points which lie within the circle. For n between 1 and 1000, plot the relative error - #/t. Also plot the function 1/v on the same plot. How do the relative errors compare to this function? (d) (OPTIONAL) Above we used simulation to compute the area of a unit circle. Using a similar process, we can find the volume of a 'sphere' in n dimensions. Estimate this volume for dimensions de {2,3,..., 20), using 100,000 samples in each dimension. How does your estimate of the volume of the sphere behave as the dimension increases? Also, do your estimates seem smooth or noisy (and if the latter, why)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!