Class ZigguratSampler

java.lang.Object
org.apache.commons.rng.sampling.distribution.ZigguratSampler
All Implemented Interfaces:
ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
Direct Known Subclasses:
ZigguratSampler.Exponential, ZigguratSampler.NormalizedGaussian

public abstract class ZigguratSampler extends Object implements SharedStateContinuousSampler
Modified ziggurat method for sampling from Gaussian and exponential distributions.

Uses the algorithm from:

McFarland, C.D. (2016)
"A modified ziggurat algorithm for generating exponentially and normally distributed pseudorandom numbers".
Journal of Statistical Computation and Simulation 86, 1281-1294.

Note: The algorithm is a modification of the Marsaglia and Tsang "Ziggurat" method. The modification improves performance by:

  1. Creating layers of the ziggurat entirely inside the probability density function (area B); this allows the majority of samples to be obtained without checking if the value is in the region of the ziggurat layer that requires a rejection test.
  2. For samples not within the main ziggurat (area A) alias sampling is used to choose a layer and rejection of points above the PDF is accelerated using precomputation of triangle regions entirely below or above the curve.
          \
----------+\
          | \
   B      |A \
-------------+\
             | \

Sampling uses UniformRandomProvider.nextLong().

Since:
1.4
See Also: