Montecarlo Method

Submitted by: Submitted by

Views: 198

Words: 308

Pages: 2

Category: Science and Technology

Date Submitted: 05/10/2011 09:52 AM

Report This Essay

MONTE CARLO

1. Plot the estimated value of π as a function of N. Use error bars to show its spread for each N. Superimpose the value of π. What happens to the estimated value of π as N increases?

The red squares are the data points for the estimated values of π while the blue diamonds are the points for the actual value of π.

Clearly, we can see from the plot that as N increases the estimated value of π becomes more accurate. At around N = 1000, the estimate of the value of π starts to get more accurate.

2. Plot the difference of the estimated value from π as a function of N. What are the minimum values of N needed such that the estimated value is accurate within 1, 2, 3, 4 or 5 significant figures?

Above, is the plot of the difference between the actual value of π and the estimated value of π versus the number of iterations.

For N = 5, we obtain the estimated value of π as 3.200000000 (1 significant figure)

For N = 18, we obtain the estimated value of π as 3.111111111 (2 significant figures)

For N = 94, we obtain the estimated value of π as 3.14893617021 (3 significant figures)

For N = 396, we obtain the estimated value of π as 3.14141414141 (4 significant figures)

For N = 3378, we obtain the estimated value of π as 3.14150384843 (5 significant figures)

For N = 4315, we obtain the estimated value of π as 3.14159907300 which is the closest estimate generated by the Monte Carlo code.

3. Plot the mean run time as a function of N. Use error bars to show its standard deviation. How does the run time scale with N?

In theory, the runtime must increase linearly with increasing number of N.