Struct rand_distr::Zeta
source · [−]pub struct Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,{ /* private fields */ }
Expand description
Samples integers according to the zeta distribution.
The zeta distribution is a limit of the Zipf
distribution. Sometimes it
is called one of the following: discrete Pareto, Riemann-Zeta, Zipf, or
Zipf–Estoup distribution.
It has the density function f(k) = k^(-a) / C(a)
for k >= 1
, where a
is the parameter and C(a)
is the Riemann zeta function.
Example
use rand::prelude::*;
use rand_distr::Zeta;
let val: f64 = thread_rng().sample(Zeta::new(1.5).unwrap());
println!("{}", val);
Remarks
The zeta distribution has no upper limit. Sampled values may be infinite. In particular, a value of infinity might be returned for the following reasons:
- it is the best representation in the type
F
of the actual sample. - to prevent infinite loops for very small
a
.
Implementation details
We are using the algorithm from Non-Uniform Random Variate Generation, Section 6.1, page 551.
Implementations
sourceimpl<F> Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
impl<F> Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
Trait Implementations
sourceimpl<F: Clone> Clone for Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
impl<F: Clone> Clone for Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
sourceimpl<F: Debug> Debug for Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
impl<F: Debug> Debug for Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
sourceimpl<F> Distribution<F> for Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
impl<F> Distribution<F> for Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> F
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> F
Generate a random value of
T
, using rng
as the source of randomness.sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘNotable traits for DistIter<D, R, T>impl<D, R, T> Iterator for DistIter<D, R, T>where
D: Distribution<T>,
R: Rng, type Item = T;
where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘNotable traits for DistIter<D, R, T>impl<D, R, T> Iterator for DistIter<D, R, T>where
D: Distribution<T>,
R: Rng, type Item = T;
where
R: Rng,
D: Distribution<T>,
R: Rng, type Item = T;
Create an iterator that generates random values of
T
, using rng
as
the source of randomness. Read moreimpl<F: Copy> Copy for Zeta<F>where
F: Float,
Standard: Distribution<F>,
OpenClosed01: Distribution<F>,
Auto Trait Implementations
impl<F> RefUnwindSafe for Zeta<F>where
F: RefUnwindSafe,
impl<F> Send for Zeta<F>where
F: Send,
impl<F> Sync for Zeta<F>where
F: Sync,
impl<F> Unpin for Zeta<F>where
F: Unpin,
impl<F> UnwindSafe for Zeta<F>where
F: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ToOwned for Twhere
T: Clone,
impl<T> ToOwned for Twhere
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
Uses borrowed data to replace owned data, usually by cloning. Read more