Copyright (C) 2015, 2017-2021 Vincent A. Cicirello.
Packages and Releases | |
---|---|
Build Status | |
JaCoCo Test Coverage | |
DOI | |
License |
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:
- G. Marsaglia and W. W. Tsang. The ziggurat method for generating random variables. Journal of Statistical Software. 5(1):1–7, 2000.
- P. H. W. Leong, G. Zhang, D. Lee, W. Luk, and J. Villasenor. A Comment on the Implementation of the Ziggurat Method. Journal of Statistical Software. 12(7):1–4, 2005.
- J. Voss. The Ziggurat Method for Generating Gaussian Random Numbers. GSL: GNU Scientific Library. 2005.
The jars of the library, distributed via Maven Central, GitHub Packages, and GitHub Releases, are built with OpenJDK 11.
If you want to build from the source, then execute mvn package
at the root
of the repository.
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>
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>
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.
The example programs in this repository are licensed under the GNU General Public License 3.0.