A data structure containing all the data that is needed to implement Marsaglia & Tang's "ziggurat" algorithm for sampling certain kinds of random distributions.
The documentation here is probably not sufficient to tell a user exactly how to build one of these from scratch, but it is not really intended to be. There are several helper functions that will build Ziggurats. The pathologically curious may wish to read the runZiggurat source. That is the ultimate specification of the semantics of all these fields.
Constructors
ZigguratzTable_xs :: !v tThe X locations of each bin in the distribution. Bin 0 is the
infiniteone.In the case of bin 0, the value given is sort of magical - x[0] is defined to be V/f(R). It's not actually the location of any bin, but a value computed to make the algorithm more concise and slightly faster by not needing to specially-handle bin 0 quite as often. If you really need to know why it works, see the runZiggurat source or "the literature" - it's a fairly standard setup.
zTable_y_ratios :: !v tThe ratio of each bin's Y value to the next bin's Y value
zTable_ys :: !v tThe Y value (zFunc x) of each bin
zGetIU :: !forall (m :: Type -> Type). RVarT m (Int, t)An RVar providing a random tuple consisting of:
a bin index, uniform over [0,c) :: Int (where
cis the number of bins in the tables)a uniformly distributed fractional value, from -1 to 1 if not mirrored, from 0 to 1 otherwise.
This is provided as a single RVar because it can be implemented more efficiently than naively sampling 2 separate values - a single random word (64 bits) can be efficiently converted to a double (using 52 bits) and a bin number (using up to 12 bits), for example.
zTailDist :: forall (m :: Type -> Type). RVarT m tThe distribution for the final "virtual" bin (the ziggurat algorithm does not handle distributions that wander off to infinity, so another distribution is needed to handle the last "bin" that stretches to infinity)
zUniform :: !forall (m :: Type -> Type). t -> t -> RVarT m tA copy of the uniform RVar generator for the base type, so that
Distribution Uniform tis not needed when sampling from a Ziggurat (makes it a bit more self-contained).zFunc :: !t -> tThe (one-sided antitone) PDF, not necessarily normalized
zMirror :: !BoolA flag indicating whether the distribution should be mirrored about the origin (the ziggurat algorithm in its native form only samples from one-sided distributions. By mirroring, we can extend it to symmetric distributions such as the normal distribution)
Instances1Distribution
(Num t, Ord t, Vector v t) => Distribution (Ziggurat v) tDefined in random-fu-0.3.0.1 · Data.Random.Distribution.Ziggurat