Giter Site home page Giter Site logo

cicirello / zigguratgaussian Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 447 KB

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

License: GNU General Public License v3.0

Java 100.00%
gaussian ziggurat java normal normal-distribution gaussian-distribution ziggurat-algorithm

zigguratgaussian's Introduction

Ziggurat Gaussian

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

Copyright (C) 2015, 2017-2023 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.

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:

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.

<dependency>
  <groupId>org.cicirello</groupId>
  <artifactId>ziggurat</artifactId>
  <version>1.0.4</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:

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

zigguratgaussian's People

Contributors

cicirello avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mkanal

zigguratgaussian's Issues

Enable MuseDev scanning on repository

Summary

Enable MuseDev scanning on repository for all pull requests to regularly scan for vulnerabilities, bugs, and error prone code that may lead to bugs. For Java, MuseDev includes the following tools: ErrorProne, Infer, and FindSecBugs,

Fix Sonatype Lift configuration

Summary

The configuration file for Sonatype Lift includes an unnecessary exclusion for the source code of the test cases. The default exclusions should cover that.

Remove support for the JitPack artifact repository

Summary

Remove support for the JitPack artifact repository. The JitPack artifact repository that enables importing packages from GitHub repositories appears to no longer be actively maintained. They have hundreds of open issues, without any maintainers even commenting on any of them. And no pull requests have been merged ni their repository in quite some time. We only added JitPack configuration as a backup in case of outages with Maven Central, which should be the preferred artifact repository. A fallback option that is not properly maintained is rather pointless.

This Issue requires:

  • Removing the JitPack configuration file.
  • Removing any JitPack specific workflows.
  • Removing workflow steps related specifically to JitPack.
  • Updating documentation in README to remove reference to JitPack, including any badges.
  • Removing any reference to JitPack from website.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.