13 stable releases (7 major)

7.0.1 Aug 13, 2023
7.0.0 Dec 25, 2020
6.1.0 Oct 22, 2019
6.0.0 Jun 28, 2019
0.2.0 Jan 23, 2017

#52 in Algorithms

Download history 6266/week @ 2024-01-03 6896/week @ 2024-01-10 6247/week @ 2024-01-17 7123/week @ 2024-01-24 7542/week @ 2024-01-31 6400/week @ 2024-02-07 5207/week @ 2024-02-14 5704/week @ 2024-02-21 7951/week @ 2024-02-28 8530/week @ 2024-03-06 9658/week @ 2024-03-13 10905/week @ 2024-03-20 9853/week @ 2024-03-27 13051/week @ 2024-04-03 11069/week @ 2024-04-10 8262/week @ 2024-04-17

44,145 downloads per month
Used in 15 crates (11 directly)

Apache-2.0

15KB
152 lines

rust-zipf

Crates.io Documentation Codecov Dependency 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:

$ cargo +nightly bench
test tests::bench_randomkit ... bench:         339 ns/iter (+/- 18)
test tests::bench_us        ... bench:          68 ns/iter (+/- 1)
test tests::bench_threadrng ... bench:          11 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).

Dependencies

~310KB