zigguratgaussian

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

https://github.com/cicirello/zigguratgaussian

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.3%) to scientific vocabulary

Keywords

gaussian gaussian-distribution java normal normal-distribution ziggurat ziggurat-algorithm

Keywords from Contributors

randomization mesh metaheuristic sequences scheduling interactive
Last synced: 4 months ago · JSON representation ·

Repository

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

Basic Info
  • Host: GitHub
  • Owner: cicirello
  • License: gpl-3.0
  • Language: Java
  • Default Branch: master
  • Homepage:
  • Size: 556 KB
Statistics
  • Stars: 7
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 8
Topics
gaussian gaussian-distribution java normal normal-distribution ziggurat ziggurat-algorithm
Created over 6 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog License Citation Zenodo

README.md

Ziggurat Gaussian

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

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

| Packages and Releases | Maven Central GitHub release (latest by date) | | :--- | :--- | | Build Status | build CodeQL | | JaCoCo Test Coverage | coverage branches coverage | | Security | Snyk security score Snyk Known Vulnerabilities | | DOI | DOI | | Other Information | GitHub style | | Support | GitHub Sponsors Liberapay Ko-Fi |

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.

When to Use This Library

The following table summarizes when this library will speed up Gaussian random number generation relative to Java's builtin functionality:

| Java Version | Significantly Faster For | | --- | --- | | Java 11 ≤ version < Java 17 | Random, SecureRandom, SplittableRandom,ThreadLocalRandom | | Java version ≥ Java 17 | Random, SecureRandom, ThreadLocalRandom |

Source code and data of experiments with Java 17 can be found in the experiment directory. The following paper discusses experiments using the library with Java 17. In Java 17, several enhancements to random number generation were introduced, including several new random number geenrators a RandomGenerator interface, and a modified ziggurat for the new random number generators as well as for SplittableRandom. The other legacy generators still use the slow polar method, however. This report explores how and where our ziggurat library is still relevant in Java 17.

Vincent A. Cicirello. 2024. Fast Gaussian Distributed Pseudorandom Number Generation in Java via the Ziggurat Algorithm. arXiv:2405.19493, May 2024. doi:10.48550/arXiv.2405.19493. [PDF]

You can find some additional 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. [PDF].

Background on the Algorithm Itself

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.

See ρμ for Expanded Functionality

The entirety of this library has been absorbed by ρμ, a Java library of Randomization enHancements and Other Math Utilities, which includes additional enhanced random number generation, among other related functionality. However, ρμ requires Java 17+, whereas this Ziggurat implementation supports Java 11+.

Versioning Scheme

The library uses Semantic Versioning with version numbers of the form: MAJOR.MINOR.PATCH, where differences in MAJOR correspond to incompatible API changes, differences in MINOR correspond to introduction of backwards compatible new functionality, and PATCH corresponds to backwards compatible bug fixes.

Java 11+

The jars of the library, distributed via Maven Central, GitHub Packages, and GitHub Releases, are built with OpenJDK 17 but for a target of Java 11.

Importing from Package Repositories

Prebuilt artifacts are regularly published to Maven Central and GitHub Packages. In most cases, you'll want to use Maven Central. Releases are published to GitHub Packages mainly as a fall-back in the unlikely scenario that Maven Central is unavailable.

Importing 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.

XML <dependency> <groupId>org.cicirello</groupId> <artifactId>ziggurat</artifactId> <version>1.0.5</version> </dependency>

Importing from GitHub Packages

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

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

Note that GitHub Packages requires authenticating to GitHub.

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.

Build with Maven

If you want to build from the source, then execute mvn package at the root of the repository. The library should build with Java 11+.

To include generation of a code coverage report during the build, execute mvn package -Pcoverage at the root of the repository to enable a Maven profile that executes JaCoCo during the test phase.

To run all static analysis tools (i.e., SpotBugs, Find Security Bugs, refactor-first), execute mvn package -Panalysis to enable a Maven profile that executes the various static analysis tools that we are using. The SpotBugs html report will be found in the target directory, or you can use the SpotBugs GUI with: mvn spotbugs:gui -Panalysis. The refactor-first report will be found in the target/site directory.

To run all of the above: mvn package -P "analysis,coverage".

License

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

Owner

  • Name: Vincent A. Cicirello
  • Login: cicirello
  • Kind: user
  • Location: Galloway, NJ
  • Company: Stockton University

Vincent A. Cicirello is a researcher in AI, evolutionary computation, and swarm intelligence.

Citation (CITATION.cff)

cff-version: "1.2.0"
message: "If you use this software, please cite it as below."
authors: 
- family-names: "Cicirello"
  given-names: "Vincent A"
  orcid: "https://orcid.org/0000-0003-1072-8559"
title: "Fast Gaussian Distributed Pseudorandom Number Generation in Java via the Ziggurat Algorithm"
doi: "10.5281/zenodo.4106912"
license: "GPL-3.0-or-later"
url: "https://github.com/cicirello/ZigguratGaussian"
preferred-citation:
  type: report
  authors:
  - family-names: "Cicirello"
    given-names: "Vincent A"
    orcid: "https://orcid.org/0000-0003-1072-8559"
  doi: "10.48550/arXiv.2405.19493"
  month: 5
  year: 2024
  title: "Fast Gaussian Distributed Pseudorandom Number Generation in Java via the Ziggurat Algorithm"
  identifiers:
  - type: other
    value: "arXiv:2405.19493"
    description: "arXiv preprint"
  - type: doi
    value: 10.48550/arXiv.2405.19493
    description: "The DOI of the report"
  - type: url
    value: "https://reports.cicirello.org/24/009/ALG-24-009.pdf"
    description: "A full-text pdf of the report"

GitHub Events

Total
  • Release event: 1
  • Watch event: 1
  • Delete event: 27
  • Issue comment event: 4
  • Push event: 38
  • Pull request review event: 29
  • Pull request event: 60
  • Create event: 30
Last Year
  • Release event: 1
  • Watch event: 1
  • Delete event: 27
  • Issue comment event: 4
  • Push event: 38
  • Pull request review event: 29
  • Pull request event: 60
  • Create event: 30

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 275
  • Total Committers: 2
  • Avg Commits per committer: 137.5
  • Development Distribution Score (DDS): 0.473
Past Year
  • Commits: 49
  • Committers: 2
  • Avg Commits per committer: 24.5
  • Development Distribution Score (DDS): 0.02
Top Committers
Name Email Commits
dependabot[bot] 4****] 145
Vincent A. Cicirello c****o 130

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 14
  • Total pull requests: 250
  • Average time to close issues: 3 days
  • Average time to close pull requests: about 10 hours
  • Total issue authors: 2
  • Total pull request authors: 3
  • Average comments per issue: 0.07
  • Average comments per pull request: 0.2
  • Merged pull requests: 239
  • Bot issues: 1
  • Bot pull requests: 217
Past Year
  • Issues: 0
  • Pull requests: 79
  • Average time to close issues: N/A
  • Average time to close pull requests: about 14 hours
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.19
  • Merged pull requests: 74
  • Bot issues: 0
  • Bot pull requests: 77
Top Authors
Issue Authors
  • cicirello (13)
  • dependabot[bot] (1)
Pull Request Authors
  • dependabot[bot] (214)
  • cicirello (33)
  • github-actions[bot] (3)
Top Labels
Issue Labels
cicd (5) github_actions (3) java (2) refactor (1) dependencies (1)
Pull Request Labels
dependencies (214) java (185) github_actions (33) documentation (11) cicd (6) hacktoberfest-accepted (4) enhancement (4) refactor (1)

Dependencies

.github/workflows/build.yml actions
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
  • actions/upload-artifact v3 composite
  • cicirello/jacoco-badge-generator v2 composite
.github/workflows/codeql-analysis.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/maven-publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
pom.xml maven
  • org.junit.jupiter:junit-jupiter 5.9.2 test