Available on crate feature
generators only.Expand description
Seeded RNG + sampling + combinatorics helpers for the generators.
We drive rand_pcg::Pcg64Mcg through the version-stable rand_core traits
(SeedableRng::seed_from_u64 + RngCore::next_u64) and derive all sampling
primitives ourselves. This sidesteps rand 0.10’s Rng/RngExt trait split
(the probe showed random_range moved to RngExt) and guarantees a fixed,
documented f64 construction for cross-build reproducibility.
Functions§
- choice_
without_ replacement - Sample
kdistinct indices from0..pool_len(partial Fisher–Yates). Returns them in draw order. Requiresk <= pool_len. - comb
- Exact binomial coefficient
C(n, k)(0 ifk > n). Multiplicative form, integer-exact because the running product ofkconsecutive integers is divisible byk!at each step. - geometric
- The geometric sampler (number of trials to first success), clamped to
>= 1. - index_
to_ edge_ comb - Map a linear index to the
m-combination of0..nat that index (sorted, strictly increasing). Port of_index_to_edge_comb(uniform.py:457). - index_
to_ edge_ prod - Map a linear index to an
m-tuple over0..nwith repetition (product order, last coordinate fastest). Port of_index_to_edge_prod(uniform.py:405). - random_
below - A uniform integer in
[0, n). Panics via debug-assert ifn == 0. Uses modulo reduction (deterministic; slight low-bit bias is acceptable — generator conformance is structural, not sequence-exact). - seeded_
rng - Build a
Pcg64Mcgfrom an optional seed.Noneuses a fixed default seed so that “unseeded” callers are STILL deterministic within a process/build (III.7: non-determinism is a bug — we never reach for entropy). - uniform_
f64 - A uniform f64 in
[0, 1)from 53 bits of the generator (IEEE-754 double mantissa). Fixed construction:(next_u64() >> 11) / 2^53.