Apache Commons RNG Examples Quadrature

The quadrature test application will output an approximation for π (3.14159...) using Monte-Carlo integration. The application generates random points within a unit box and counts the number of points within the unit circle. The approximation to π is made using the ratio of the points within the circle to the total number of points, which should be π/4.

Build the application using:

    mvn package -P examples-quadrature

Run the application using 2 arguments:

  1. The number of random points
  2. The name of the random generator

For example:

    java -jar target/examples-quadrature.jar 1000000 KISS

This will output:

    After generating 2000000 random numbers, the error on |𝛑 - 3.14224| is 6.473464102070281E-4