mersenne-random-pure64-0.2.0.4: Generate high quality pseudorandom numbers purely using a Mersenne Twister

PortabilityCPP, FFI
Stabilityexperimental
MaintainerDon Stewart <dons@galois.com>
Safe HaskellNone

System.Random.Mersenne.Pure64

Contents

Description

Tested with: GHC 6.8.3

A purely functional binding 64 bit binding to the classic mersenne twister random number generator. This is more flexible than the impure 'mersenne-random' library, at the cost of being a bit slower. This generator is however, many times faster than System.Random, and yields high quality randoms with a long period.

This generator may be used with System.Random, however, that is likely to be slower than using it directly.

Synopsis

The random number generator

data PureMT Source

PureMT, a pure mersenne twister pseudo-random number generator

Instances

Show PureMT 
RandomGen PureMT 

Introduction

pureMT :: Word64 -> PureMTSource

Create a PureMT generator from a Word64 seed.

newPureMT :: IO PureMTSource

Create a new PureMT generator, using the clocktime as the base for the seed.

Being purely functional, the PureMT generator is an instance of RandomGen. However, it doesn't support split yet.

Low level access to the generator

randomInt :: PureMT -> (Int, PureMT)Source

Yield a new Int value from the generator, returning a new generator and that Int. The full 64 bits will be used on a 64 bit machine.

randomWord :: PureMT -> (Word, PureMT)Source

Yield a new Word value from the generator, returning a new generator and that Word.

randomInt64 :: PureMT -> (Int64, PureMT)Source

Yield a new Int64 value from the generator, returning a new generator and that Int64.

randomWord64 :: PureMT -> (Word64, PureMT)Source

Yield a new Word64 value from the generator, returning a new generator and that Word64.

randomDouble :: PureMT -> (Double, PureMT)Source

Efficiently yield a new 53-bit precise Double value, and a new generator.