Skip to content

Commit

Permalink
Merge pull request #1136 from vks/zipf
Browse files Browse the repository at this point in the history
rand_distr: Add Zipf distribution
  • Loading branch information
vks committed Aug 4, 2021
2 parents 81b8a75 + fe5a6e1 commit b39e35f
Show file tree
Hide file tree
Showing 4 changed files with 387 additions and 1 deletion.
3 changes: 3 additions & 0 deletions rand_distr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- New `Zeta` and `Zipf` distributions (#1136)

## [0.4.1] - 2021-06-15
- Empirically test PDF of normal distribution (#1121)
- Correctly document `no_std` support (#1100)
Expand Down
6 changes: 6 additions & 0 deletions rand_distr/benches/src/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
distr_float!(g, "poisson", f64, Poisson::new(4.0).unwrap());
}

{
let mut g = c.benchmark_group("zipf");
distr_float!(g, "zipf", f64, Zipf::new(10, 1.5).unwrap());
distr_float!(g, "zeta", f64, Zeta::new(1.5).unwrap());
}

{
let mut g = c.benchmark_group("bernoulli");
distr!(g, "bernoulli", bool, Bernoulli::new(0.18).unwrap());
Expand Down
5 changes: 4 additions & 1 deletion rand_distr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
//! - [`Poisson`] distribution
//! - [`Exp`]onential distribution, and [`Exp1`] as a primitive
//! - [`Weibull`] distribution
//! - [`Zeta`] distribution
//! - [`Zipf`] distribution
//! - Gamma and derived distributions:
//! - [`Gamma`] distribution
//! - [`ChiSquared`] distribution
Expand Down Expand Up @@ -115,6 +117,7 @@ pub use self::unit_circle::UnitCircle;
pub use self::unit_disc::UnitDisc;
pub use self::unit_sphere::UnitSphere;
pub use self::weibull::{Error as WeibullError, Weibull};
pub use self::zipf::{ZetaError, Zeta, ZipfError, Zipf};
#[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
pub use rand::distributions::{WeightedError, WeightedIndex};
Expand Down Expand Up @@ -198,4 +201,4 @@ mod unit_sphere;
mod utils;
mod weibull;
mod ziggurat_tables;

mod zipf;

0 comments on commit b39e35f

Please sign in to comment.