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
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:
- 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.
- 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classModified ziggurat method for sampling from an exponential distribution.static final classModified ziggurat method for sampling from a Gaussian distribution with mean 0 and standard deviation 1. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContinuousSampler
sample, samples, samplesMethods inherited from interface SharedStateSampler
withUniformRandomProvider