Skip to content

Commit b39e35f

Browse files
authored
Merge pull request #1136 from vks/zipf
rand_distr: Add Zipf distribution
2 parents 81b8a75 + fe5a6e1 commit b39e35f

File tree

4 files changed

+387
-1
lines changed

4 files changed

+387
-1
lines changed

rand_distr/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
- New `Zeta` and `Zipf` distributions (#1136)
9+
710
## [0.4.1] - 2021-06-15
811
- Empirically test PDF of normal distribution (#1121)
912
- Correctly document `no_std` support (#1100)

rand_distr/benches/src/distributions.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
195195
distr_float!(g, "poisson", f64, Poisson::new(4.0).unwrap());
196196
}
197197

198+
{
199+
let mut g = c.benchmark_group("zipf");
200+
distr_float!(g, "zipf", f64, Zipf::new(10, 1.5).unwrap());
201+
distr_float!(g, "zeta", f64, Zeta::new(1.5).unwrap());
202+
}
203+
198204
{
199205
let mut g = c.benchmark_group("bernoulli");
200206
distr!(g, "bernoulli", bool, Bernoulli::new(0.18).unwrap());

rand_distr/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
//! - [`Poisson`] distribution
5757
//! - [`Exp`]onential distribution, and [`Exp1`] as a primitive
5858
//! - [`Weibull`] distribution
59+
//! - [`Zeta`] distribution
60+
//! - [`Zipf`] distribution
5961
//! - Gamma and derived distributions:
6062
//! - [`Gamma`] distribution
6163
//! - [`ChiSquared`] distribution
@@ -115,6 +117,7 @@ pub use self::unit_circle::UnitCircle;
115117
pub use self::unit_disc::UnitDisc;
116118
pub use self::unit_sphere::UnitSphere;
117119
pub use self::weibull::{Error as WeibullError, Weibull};
120+
pub use self::zipf::{ZetaError, Zeta, ZipfError, Zipf};
118121
#[cfg(feature = "alloc")]
119122
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
120123
pub use rand::distributions::{WeightedError, WeightedIndex};
@@ -198,4 +201,4 @@ mod unit_sphere;
198201
mod utils;
199202
mod weibull;
200203
mod ziggurat_tables;
201-
204+
mod zipf;

0 commit comments

Comments
 (0)