#random #distribution #byte #precision #rational #generic

no-std bernoulli

An exact Bernoulli distribution

1 unstable release

0.1.0 Oct 18, 2021

#2523 in Algorithms

MIT/Apache

15KB
283 lines

Bernoulli

A generic replacement for rand::distributions::Bernoulli which uses exact precision instead of a 64-bit approximation, bernoulli::BernoulliExact<T> provides an exact distribution for any rational value representable by T.

BernoulliExact<u32> performs on-par with Bernoulli, though with a non-trivial memory overhead.

Type Size
Bernoulli 8 bytes
BernoulliExact<u32> 20 bytes
BernoulliExact<u8> 5 bytes

Dependencies

~335–460KB