Fast Gaussian Distributed Pseudorandom Number Generation in Java via the Ziggurat Algorithm

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
1. Verfasser: Cicirello, Vincent A.
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866916265731293184
author Cicirello, Vincent A.
author_facet Cicirello, Vincent A.
contents We report on experiments with the ziggurat algorithm for generating Gaussian distributed random numbers. The study utilizes our open source Java implementation that was introduced originally for Java 11 at a time when the Java API only provided the much slower polar method. Our Java implementation of the ziggurat algorithm is a port of the GNU Scientific Library's C implementation. Java 17 introduced a significant overhaul of pseudorandom number generation, including several modern pseudorandom number generators (PRNGs) as well as additional functionality, among which includes switching from the polar method to a modified ziggurat algorithm. In the experiments of this paper, we explore whether there is still a need for our implementation for Java 17+ applications. Our results show that Java 17's modified ziggurat is faster than our implementation for the PRNGs that support it. However, Java 17+ continues to use the polar method for the legacy PRNGs Random, SecureRandom, and ThreadLocalRandom. The linear congruential method of Java's Random class lacks the statistical properties required by Java's modified ziggurat implementation; and SecureRandom and ThreadLocalRandom unfortunately use the polar method as a side-effect of extending Random. Our implementation of the original ziggurat algorithm does not require the same statistical properties of the underlying PRNG as Java 17's optimized version, and can be used with any of these PRNGs, and is especially relevant where pre-Java 17 support is required.
format Preprint
id arxiv_https___arxiv_org_abs_2405_19493
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Fast Gaussian Distributed Pseudorandom Number Generation in Java via the Ziggurat Algorithm
Cicirello, Vincent A.
Data Structures and Algorithms
Discrete Mathematics
Probability
68Q87, 68W20, 60-04, 60G15, 65C10
F.2.1; I.1.2; D.2.13; G.3; G.4
We report on experiments with the ziggurat algorithm for generating Gaussian distributed random numbers. The study utilizes our open source Java implementation that was introduced originally for Java 11 at a time when the Java API only provided the much slower polar method. Our Java implementation of the ziggurat algorithm is a port of the GNU Scientific Library's C implementation. Java 17 introduced a significant overhaul of pseudorandom number generation, including several modern pseudorandom number generators (PRNGs) as well as additional functionality, among which includes switching from the polar method to a modified ziggurat algorithm. In the experiments of this paper, we explore whether there is still a need for our implementation for Java 17+ applications. Our results show that Java 17's modified ziggurat is faster than our implementation for the PRNGs that support it. However, Java 17+ continues to use the polar method for the legacy PRNGs Random, SecureRandom, and ThreadLocalRandom. The linear congruential method of Java's Random class lacks the statistical properties required by Java's modified ziggurat implementation; and SecureRandom and ThreadLocalRandom unfortunately use the polar method as a side-effect of extending Random. Our implementation of the original ziggurat algorithm does not require the same statistical properties of the underlying PRNG as Java 17's optimized version, and can be used with any of these PRNGs, and is especially relevant where pre-Java 17 support is required.
title Fast Gaussian Distributed Pseudorandom Number Generation in Java via the Ziggurat Algorithm
topic Data Structures and Algorithms
Discrete Mathematics
Probability
68Q87, 68W20, 60-04, 60G15, 65C10
F.2.1; I.1.2; D.2.13; G.3; G.4
url https://arxiv.org/abs/2405.19493