rust-zipf

crates.io page Downloads Documentation Build Status

Rust implementation of a fast, discrete, bounded, Zipf-distributed random number generator. Compared to the implementation provided by randomkit (which binds to NumPy's fork of RandomKit), this crate is approximately twice as fast:

console $ cargo +nightly bench test tests::bench_randomkit ... bench: 344 ns/iter (+/- 15) test tests::bench_us ... bench: 66 ns/iter (+/- 2) test tests::bench_threadrng ... bench: 9 ns/iter (+/- 0)

It is also both driven by, and provides, a Rust random number generator.

This implementation is effectively a direct port of Apache Common's RejectionInversionZipfSampler, written in Java. It is based on the method described by Wolfgang Hörmann and Gerhard Derflinger in Rejection-inversion to generate variates from monotone discrete distributions from ACM Transactions on Modeling and Computer Simulation (TOMACS) 6.3 (1996).