Cryptographically secure n-sided dice via rejection sampling. http://monoid.at/code
|Latest on Hackage:||22.214.171.124|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
This library uses rejection sampling to provide cryptographically secure
n-sided dice rolls and random sampling (within a given range).
The number of used random bits is close to the information-theoretic optimal
If we wanted to use the system-specific entropy source (
produce 10 dice rolls of a 6-sided dice (i.e. range [0,5]), we could write:
> systemEntropy $$ diceRolls 6 =$= CL.take 10 [5,1,3,3,0,5,3,2,2,1]
testPerformance yields the actual number of consumed random
> testPerformance 12 10000 Generated 10000 random samples in range [0,11] Average number of bits used: 3.5904 Entropy lower bound on the number of required bits: 3.5849625007211565 Performance ratio: 1.0015167520658164
Feedback is welcome!