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, at that time, was 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:
- 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.static double
nextGaussian
(double sigma) Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, of your choosing.static double
nextGaussian
(double sigma, RandomGenerator r) Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, of your choosing.static double
Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.
-
Method Details
-
nextGaussian
public static double nextGaussian(double sigma) Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, of your choosing.ThreadLocalRandom
is used as the pseudorandom number generator for the source of randomness.- Parameters:
sigma
- The standard deviation of the Gaussian.- Returns:
- A random number from a Gaussian distribution with mean 0 and standard deviation sigma.
-
nextGaussian
Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, of your choosing.- Parameters:
sigma
- The standard deviation of the Gaussian.r
- The pseudorandom number generator to use for the source of randomness.- Returns:
- A random number from a Gaussian distribution with mean 0 and standard deviation sigma.
-
nextGaussian
public static double nextGaussian()Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.ThreadLocalRandom
is used as the pseudorandom number generator for the source of randomness.- Returns:
- A random number from a Gaussian distribution with mean 0 and standard deviation 1.
-
nextGaussian
Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.- Parameters:
r
- The pseudorandom number generator to use for the source of randomness.- Returns:
- A random number from a Gaussian distribution with mean 0 and standard deviation 1.
-