dice-entropy-conduit-1.0.0.0: Cryptographically secure n-sided dice via rejection sampling.

Portabilityportable
Stabilityexperimental
MaintainerPeter Robinson <peter.robinson@monoid.at>
Safe HaskellNone

System.Random.Dice.Internal

Description

 

Synopsis

Documentation

integralToBitsSource

Arguments

:: (Integral n, Integral m) 
=> Int

minimal number of bits b

-> n

the number n

-> [m]

bit representation of n, length >= b

Converts a number to its base-2 representation (as a list of bits) and prepends zeros to ensure the minimal size.

bitsToIntegral :: Integral n => [n] -> nSource

Convert a list of bits to an integral

upperBound :: Word64Source

Upper bound on the number of sides that a random dice can have.

getDiceRollsSource

Arguments

:: Int

n: number of sides

-> Int

k: number of rolls

-> IO [Int] 

Generates k rolls of an n sided dice.

getRandomRsSource

Arguments

:: (Int, Int)

(inclusive) range

-> Int

number of samples

-> IO [Int] 

Generates a list of random integer values in the specified range.

diceRolls :: Int -> Conduit Word8 IO IntSource

Produces a stream of random integer values in the range [0,n-1], for a given n <= 2^55. This conduit needs to be attached to an entropy source such as systemEntropy.

randomRsSource

Arguments

:: (Int, Int)

range (inclusive)

-> Conduit Word8 IO Int 

Produces a stream of random integer values within a range. This conduit needs to be attached to an entropy source such as systemEntropy.

systemEntropy :: Producer IO Word8Source

A source of entropy. By default, we use the getEntropy function from the entropy package, see systemEntropy.

Warning: When combining a source of entropy with another conduits, it is important to ensure that there is no "backflow" due to leftover values that are being returned to the source from the conduit. This can be done by fusing the conduit with the identity map, e.g: myEntropySrc $$ Data.Conduit.List.map id =$= myConduit

dRoll :: Word64 -> Word64 -> Word64 -> Conduit Word8 IO (Int, Int)Source

Internal function. Should not be invoked directly.

testPerformanceSource

Arguments

:: Int

number of sides of dice

-> Int

number of samples used for computing average.

-> IO () 

Compute the performance of the algorithm in terms of used random bits versus produced random values.