Expand description
The technique of choice, plus integration with the rand crate.
This module is an alias for pekkizen, whose
leading-zeros technique provides complete coverage of [0 . . 1) at
almost the cost of the 53-bit division scaling, consuming one
64-bit word per call with probability 1 − 2⁻¹².
The unif_01 function converts any source of random 64-bit words;
with the rand feature (enabled by default), the Unif01Ext
extension trait additionally endows every generator implementing
rand_core::Rng with the same conversion as a unif_01
method.
Re-exports§
pub use crate::pekkizen::*;
Traits§
- Unif01
Ext - Extension trait adding a
unif_01method to every generator implementingrand_core::Rng(in particular, to the generators of therandcrate).
Functions§
- unif_01
- Returns a random
f64distributed as a uniform real in [0 . . 1) rounded down to the nearest representable value: every float in [0 . . 1) is reachable, subnormals and 0 included, with probability equal to the measure of the reals that round down to it.