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

CopyrightCopyright (c) 2008, Don Stewart <dons@galois.com>
LicenseBSD3
MaintainerDon Stewart <dons@galois.com>
Stabilityexperimental
PortabilityCPP, FFI
Safe HaskellNone
LanguageHaskell98

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

Introduction

pureMT :: Word64 -> PureMT Source #

Create a PureMT generator from a Word64 seed.

newPureMT :: IO PureMT Source #

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.

Orphan instances