#random #distribution #numbers #generator

zipf

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

14 stable releases (7 major)

new 7.0.2 Feb 8, 2025
7.0.1 Aug 13, 2023
7.0.0 Dec 25, 2020
6.1.0 Oct 22, 2019
0.2.0 Jan 23, 2017

#2526 in Algorithms

Download history 7485/week @ 2024-10-22 5688/week @ 2024-10-29 6035/week @ 2024-11-05 7214/week @ 2024-11-12 6983/week @ 2024-11-19 9343/week @ 2024-11-26 10247/week @ 2024-12-03 9863/week @ 2024-12-10 10822/week @ 2024-12-17 4091/week @ 2024-12-24 6075/week @ 2024-12-31 9755/week @ 2025-01-07 7321/week @ 2025-01-14 9170/week @ 2025-01-21 11268/week @ 2025-01-28 8812/week @ 2025-02-04

38,660 downloads per month
Used in 18 crates (14 directly)

Apache-2.0

16KB
153 lines

[!CAUTION] This crate is deprecated. Prefer rand_distr::Zipf.


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

~315KB