#random #distribution #zipf

zipf

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

12 stable releases (7 major)

7.0.0 Dec 25, 2020
6.1.0 Oct 22, 2019
6.0.1 Aug 24, 2019
6.0.0 Jun 28, 2019
0.2.0 Jan 23, 2017

#540 in Algorithms

Download history 1437/week @ 2022-11-27 1939/week @ 2022-12-04 1614/week @ 2022-12-11 1648/week @ 2022-12-18 468/week @ 2022-12-25 700/week @ 2023-01-01 616/week @ 2023-01-08 570/week @ 2023-01-15 783/week @ 2023-01-22 1509/week @ 2023-01-29 1986/week @ 2023-02-05 1426/week @ 2023-02-12 1774/week @ 2023-02-19 2213/week @ 2023-02-26 3549/week @ 2023-03-05 2808/week @ 2023-03-12

10,410 downloads per month
Used in 6 crates (5 directly)

Apache-2.0

16KB
161 lines

rust-zipf

Crates.io Documentation Build Status 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

~315KB