#random #distribution #numbers #generator

zipf

A fast generator of discrete, bounded Zipf-distributed random numbers

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

#44 in Algorithms

Download history 10525/week @ 2024-07-04 13780/week @ 2024-07-11 8979/week @ 2024-07-18 10622/week @ 2024-07-25 12085/week @ 2024-08-01 12795/week @ 2024-08-08 15701/week @ 2024-08-15 16177/week @ 2024-08-22 15537/week @ 2024-08-29 8217/week @ 2024-09-05 10111/week @ 2024-09-12 8058/week @ 2024-09-19 9935/week @ 2024-09-26 8021/week @ 2024-10-03 7850/week @ 2024-10-10 8145/week @ 2024-10-17

36,266 downloads per month
Used in 19 crates (15 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