Skip to main content

Crate entropy_pool

Crate entropy_pool 

Source
Expand description

Entropy-efficient bounded random sampling.

EntropyPool keeps an internal uniform state (b, m) and recycles the parts of that state that a bounded draw does not consume. This avoids modulo bias while allowing later draws to reuse residual entropy.

§Example

use entropy_pool::EntropyPool;

let mut pool = EntropyPool::new();

let value = pool.gen_range(6);
assert!(value < 6);

let permutation = pool.permutation(3, 10);
assert_eq!(permutation.len(), 3);

let combination = pool.combination(5, 20);
assert_eq!(combination.len(), 5);

Structs§

EntropyPool
A bounded sampler that reuses residual entropy between draws.

Enums§

EntropyPoolError
Errors returned by the checked sampling methods.