Announcing the recently registered Ziggurats.jl
. Make very high performance random number generators for whatever distributions you like! (with some modest limitations)
The ziggurat algorithm uses a carefully constructed table of precomputed values to sample random numbers distributed according to a PDF with very high efficiency. It is widely used for high performance generation of normally distributed and exponentially distributed random numbers, including in Julia’s own Random.jl
. The new package, Ziggurats.jl
, automates the process of constructing the ziggurat tables so you can get the same high performance sampling from a very wide variety of distributions. The main requirements are that the PDF must be univariate, piecewise monotonic, and must not diverge to infinite density. Even discontinuous functions should work.
Example:
julia> using Ziggurats, Plots, BenchmarkTools
julia> z = ziggurat(x->10 - x + sin(x), (0, 9.7));
julia> histogram(rand(z, 10^5))
julia> @btime rand($z)
3.920 ns (0 allocations: 0 bytes)
Check out the README on GitHub for more information: Ziggurats.jl