Class PolarGaussian
 java.lang.Object

 org.cicirello.math.rand.PolarGaussian

public final class PolarGaussian extends Object
This class provides methods for generating pseudorandom numbers from a Gaussian distribution using the classic Polar Method. Other methods exist that are faster than Polar, and with superior statistical properties over the Polar method. One such algorithm is the Ziggurat method, implemented in the
ZigguratGaussian
class. The Polar method implementation provided in the PolarGaussian class was originally implemented as part of an experimental study comparing the effects of different Gaussian algorithms on the performance of a genetic algorithm. It is included here in this repository, however, if you are looking for a fast algorithm for generating Gaussian distributed random numbers, we suggest you consider theZigguratGaussian
class instead.It should be noted that the Java API includes a polar method implementation in both the
Random
andThreadLocalRandom
classes. However, the experimental study mentioned above also included the use ofSplittableRandom
which does not provide any methods for generating Gaussian distributed random numbers. TheSplittableRandom
class is also declared final, so extending to add such a method was not an option. Our solution was a static method in this class with a parameter for the underlying pseudorandom number generator (PRNG). We chose to do the same forRandom
andThreadLocalRandom
so that our approach was consistent across all 3 PRNGs used in the study.You can find some experimental data comparing the performance of a sequential genetic algorithm (GA) using this implementation of the Polar method for Gaussian mutation vs using the faster Ziggurat method, as well as experimental data for the same comparison but with a Parallel GA, in the following paper:
 V. A. Cicirello. Impact of Random Number Generation on Parallel Genetic Algorithms. Proceedings of the ThirtyFirst International Florida Artificial Intelligence Research Society Conference, pages 27. AAAI Press, May 2018.


Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
nextGaussian()
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, or your choosing.static double
nextGaussian(double sigma, Random r)
Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or your choosing.static double
nextGaussian(double sigma, SplittableRandom r)
Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or your choosing.static double
nextGaussian(Random r)
Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.static double
nextGaussian(SplittableRandom r)
Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.



Method Detail

nextGaussian
public static double nextGaussian(double sigma)
Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or 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
public static double nextGaussian(double sigma, Random r)
Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or 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(double sigma, SplittableRandom r)
Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or 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
public static double nextGaussian(Random r)
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.

nextGaussian
public static double nextGaussian(SplittableRandom r)
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.

