Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Christopher Gunadi

CSCI 3366-1
Homework 2

Note: All Java testing was performed using Dione00.

Java Sequential

Difference from Pi

0.00085
0.0008
0.00075
0.0007
0.00065
0.0006
0.00055
0.0005
0.00045
0.0004 Difference from Pi
0.00035
0.0003
0.00025
0.0002
0.00015
0.0001
0.00005
0
1 2 3 4 5 6 7

Figure 1.) The difference between seqMonteCarloPi.java’s estimated pi and Math.PI.


Please note that the X-Axis intervals start with 500,000 samples doubling each time until
a total of 32,000,000 samples. The seed value was 103.
The Random Number Generator is a Linear Congruential Generator. The formula is as
follows:
nextSt = ((a * curSt) + c ) % m)
In this case the value for m is 2147483647. The value of a is 16807 and the value of c is
0. The results in table form are as follows:
Difference
# Samples from Pi

500000 0.000768654

1000000 0.000776654

2000000 0.000331346

4000000 6.76536E-05

8000000 0.000354346

16000000 0.000123904

32000000 3.4714E-06
Java Parallel

0.0016
0.0015
0.0014
0.0013
0.0012
0.0011
0.001
0.0009
Seed 11
0.0008
Seed 103
0.0007
Seed 9973
0.0006
0.0005
0.0004
0.0003
0.0002
0.0001
0
1 2 3 4 5 6

Figure 2) Difference from Math.PI with 32,000,000 samples and the Seeds indicated.
Number of threads are indicated along the x-axis in terms of 2 to the N-1th power.
11
10.5
10
9.5
9
8.5
8
7.5
7
6.5
6
Seed 11
5.5
5 Seed 103
4.5 Seed 9973
4
3.5
3
2.5
2
1.5
1
0.5
0
1 2 3 4 5 6

Figure 3) Y-Axis time in seconds. X-Axis number of threads are indicated along the x-
axis in terms of 2 to the N-1th power.
Number of Threads Seed 11 Seed 103 Seed 9973

1 10.394 10.378 10.385

2 5.581 5.616 5.526

4 4.902 4.892 5.647

8 4.552 5.137 5.195

16 4.313 4.43 4.351

32 4.438 4.376 4.338

Table 2) The data used to generate Figure 3.

You might also like