spec.benchmarks.scimark.monte_carlo
Class MonteCarlo

java.lang.Object
  extended by spec.benchmarks.scimark.monte_carlo.MonteCarlo

public class MonteCarlo
extends java.lang.Object

Estimate Pi by approximating the area of a circle. How: generate N random numbers in the unit square, (0,0) to (1,1) and see how are within a radius of 1 or less, i.e.


 sqrt(x^2 + y^2) < r

 
since the radius is 1.0, we can square both sides and avoid a sqrt() computation:

 x^2 + y^2 <= 1.0

 
this area under the curve is (Pi * r^2)/ 4.0, and the area of the unit of square is 1.0, so Pi can be approximated by
 # points with x^2+y^2 < 1
 Pi =~          --------------------------  * 4.0
 total # points

 


Constructor Summary
MonteCarlo()
           
 
Method Summary
 double integrate(int numSamples)
           
static void main()
           
 double measureMonteCarlo(double min_time, Random R)
           
 double num_flops(int Num_samples)
           
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MonteCarlo

public MonteCarlo()
Method Detail

main

public static void main()

num_flops

public final double num_flops(int Num_samples)

integrate

public final double integrate(int numSamples)

measureMonteCarlo

public double measureMonteCarlo(double min_time,
                                Random R)

run

public void run()