AP Statistics / Mr. Hansen
1/4/2006

Name: _________________________

Solution to Pi Simulation Exercise

 

Your task was to estimate p by performing a Monte Carlo simulation involving the first quadrant quarter circle of radius 2. Here are the steps:

 

  1. Select a random real number between 0 and 2 to serve as the x coordinate and another random real number between 0 and 2 to serve as the y coordinate. [Note: On the TI-83, this is accomplished with the function rand*2. In Excel, the formula would be =RAND()*2. If you are using the random digit table, you would take a large number of digits at a time, say 10, and treat them as decimal fraction with an implied leading decimal point, and then multiply by 2 to scale them in the range of 0 to 2.]
  2. If y < (4 – x2)0.5, that means that the random (x, y) ordered pair is within the circle. Count this as a success. Otherwise, count the event as a failure.
  3. Repeat steps 1 and 2 for a total of 30 trials.
  4. Let . Remember, the notation  means sample proportion. The sample proportion will be an unbiased estimator of the true probability p.
  5. Since » (area of quarter circle)/(area of square) = p/4, we can multiply through by 4 to conclude that .

 

Here is a tabulation of results:

 

Trial #

x

y

Success? (1=yes, 0=no)

1

1.514869

0.716877

1

2

0.523154

1.529781

1

3

0.802115

1.278847

1

4

0.415451

0.817405

1

5

0.299436

0.58402

1

6

1.850538

0.705966

1

7

1.724866

0.858874

1

8

1.247713

1.688632

0

9

0.012287

0.056046

1

10

0.223077

1.922212

1

11

1.032865

0.495525

1

12

1.332576

1.832073

0

13

1.340788

0.805873

1

14

0.71197

1.074217

1

15

0.94439

1.988424

0

16

0.602156

0.140416

1

17

0.912871

1.164401

1

18

1.564564

0.540651

1

19

0.881133

0.729464

1

20

1.945962

0.416888

1

21

0.735593

1.772785

1

22

1.748613

0.014502

1

23

0.481978

0.939933

1

24

0.71744

0.052331

1

25

1.341016

1.939306

0

26

1.389113

1.649355

0

27

1.085715

0.918535

1

28

0.693089

0.021667

1

29

1.156587

0.06176

1

30

1.291855

1.666163

0

 

 

 

 

 

 

Success count

24

= (success count)/30

0.800

 

Therefore, the estimate of p would be 4(0.800) = 3.2.

 

Using an Excel spreadsheet and a macro, I ran 5 million trials and obtained an estimate of 3.140911 for p.