public class NormalPrngextends DoublePrngClass NormalPrng provides a pseudorandom number generator (PRNG) that generates random numbers with a normal distribution.
Every two calls of the next() method result in two calls of the underlying uniform PRNG's nextDouble() method. More precisely, the first of a pair of next() calls does two nextDouble() calls, the second of a pair of next() calls does not call nextDouble().
Class NormalPrng uses the Box-Muller method to generate a standard normal distribution. Let x1 and x2 be drawn from a uniform distribution between 0 and 1. Then y1 and y2, defined as follows, are drawn from a standard normal distribution.
y1 = sqrt(−2 ln x1) cos 2πx2And (μ + σy1) and (μ + σy2) are drawn from a normal distribution with mean μ and standard deviation σ.
y2 = sqrt(−2 ln x1) sin 2πx2
Note: While slower than other techniques, this technique does a fixed number of nextDouble() calls to generate each normally distributed random number. This behavior is important when parallel programs generate random numbers.