Struct rand_distr::Zeta
source · pub struct Zeta<F>{ /* private fields */ }
Expand description
The Zeta distribution Zeta(s)
.
The Zeta distribution
is a discrete probability distribution with parameter s
.
It is a special case of the Zipf
distribution with n = ∞
.
It is also known as the discrete Pareto, Riemann-Zeta, Zipf, or Zipf–Estoup distribution.
§Density function
f(k) = k^(-s) / ζ(s)
for k >= 1
, where ζ
is the
Riemann zeta function.
§Plot
The following plot illustrates the zeta distribution for various values of s
.
§Example
use rand::prelude::*;
use rand_distr::Zeta;
let val: f64 = thread_rng().sample(Zeta::new(1.5).unwrap());
println!("{}", val);
§Notes
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
s
.
§Implementation details
We are using the algorithm from Non-Uniform Random Variate Generation, Section 6.1, page 551.
Implementations§
Trait Implementations§
source§impl<F> Distribution<F> for Zeta<F>
impl<F> Distribution<F> for Zeta<F>
impl<F> Copy for Zeta<F>
impl<F> StructuralPartialEq for Zeta<F>
Auto Trait Implementations§
impl<F> Freeze for Zeta<F>where
F: Freeze,
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)