Module

Random.LCG

Package
lcg
Repository
purescript/purescript-lcg

#Seed Source

newtype Seed

A seed for the linear congruential generator. We omit a Semiring instance because there is no zero value, as 0 is not an acceptable seed for the generator.

Instances

#mkSeed Source

#unSeed Source

#randomSeed Source

randomSeed :: Effect Seed

Create a random seed

#lcgA Source

lcgA :: Int

The multiplier: a magic constant for the linear congruential generator

#lcgC Source

lcgC :: Int

The increment: a magic constant for the linear congruential generator

#lcgM Source

lcgM :: Int

The modulus: a magic constant for the linear congruential generator. It is equal to 2^31 - 1, a Mersenne prime. It is useful for this value to be prime, because then the requirement of the initial seed being coprime to the modulus is satisfied when the seed is between 1 and lcgM - 1.

#lcgNext Source

lcgNext :: Seed -> Seed

Step the linear congruential generator

#lcgPerturb Source

lcgPerturb :: Int -> Seed -> Seed

Perturb a seed value

Modules
Random.LCG