Skip to content

Latest commit

 

History

History
98 lines (75 loc) · 5.53 KB

README.md

File metadata and controls

98 lines (75 loc) · 5.53 KB

Ziggurat Gaussian

Ziggurat Gaussian - Fast Gaussian distributed pseudorandom number generation in Java via the Ziggurat algorithm

Copyright (C) 2015, 2017-2021 Vincent A. Cicirello.

Packages and Releases Maven Central GitHub release (latest by date)
Build Status build CodeQL
JaCoCo Test Coverage coverage branches coverage
DOI DOI
License GitHub

Fast Gaussian distributed pseudorandom number generation in Java via the Ziggurat algorithm

This repository contains a Java implementation of the Ziggurat algorithm for generating Gaussian distributed pseudorandom numbers. The Ziggurat algorithm is significantly faster than the more commonly encountered Polar method, and has some other desirable statistical properties. The ZigguratGaussian class is a Java port of the GNU Scientific Library's C implementation (Voss, 2005) of the Ziggurat method. In porting to Java, we have made several optimizations, the details of which can be found in the source code comments, which highlights any differences between this Java implementation and the C implementation on which it is based.

This Java implementation originated as part of an effort to speed up the runtime of a parallel genetic algorithm (PGA). The PGA in question evolved its control parameters (i.e., crossover and mutation rates, etc) using Gaussian mutation. The only Gaussian implementation within the Java API is the polar method (nextGaussian method of the Random and ThreadLocalRandom classes, however the polar method is quite slow relative to other newer available alternatives, such as the Ziggurat method.

You can find some experimental data comparing the performance of a sequential genetic algorithm (GA) using this implementation of the Ziggurat method for Gaussian mutation vs using the more common polar method, as well as experimental data for the same comparison but with a PGA, in the following paper:

V. A. Cicirello. Impact of Random Number Generation on Parallel Genetic Algorithms. Proceedings of the Thirty-First International Florida Artificial Intelligence Research Society Conference, pages 2-7. AAAI Press, May 2018.

See the following articles for detailed description of the Ziggurat algorithm itself, as well as additional experimental data:

Java 11+

The jars of the library, distributed via Maven Central, GitHub Packages, and GitHub Releases, are built with OpenJDK 11.

Build with Maven

If you want to build from the source, then execute mvn package at the root of the repository.

Importing the Library from Maven Central

Add this to the dependencies section of your pom.xml, replacing the version number with the version that you want to use.

<dependency>
  <groupId>org.cicirello</groupId>
  <artifactId>ziggurat</artifactId>
  <version>1.0.2</version>
</dependency>

Importing the Library from GitHub Packages

If you'd prefer to import from GitHub Packages, rather than Maven Central: (1) add the dependency as indicated in previous section above, and (2) add the following to the repositories section of your pom.xml:

<repository>
  <id>github</id>
  <name>GitHub cicirello Apache Maven Packages</name>
  <url>https://maven.pkg.github.com/cicirello/ZigguratGaussian</url>
  <releases><enabled>true</enabled></releases>
  <snapshots><enabled>true</enabled></snapshots>
</repository>

Downloading Jar Files

If you don't use a dependency manager that supports importing from Maven Central, or if you simply prefer to download manually, prebuilt jars are also attached to each GitHub Release.

License

The example programs in this repository are licensed under the GNU General Public License 3.0.