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

Copyright | Copyright (c) 2008 Don Stewart <dons@galois.com>
License | BSD3
Maintainer | Don Stewart <dons@galois.com>
Stability | experimental
Portability | CPP, FFI
Safe Haskell | None
Language | Haskell98

System.Random.Mersenne.Pure64

Contents

- The random number generator
- Introduction
- Low level access to the generator
- Orphan instances

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

- data PureMT
- pureMT :: Word64 -> PureMT
- newPureMT :: IO PureMT
- randomInt :: PureMT -> (Int, PureMT)
- randomWord :: PureMT -> (Word, PureMT)
- randomInt64 :: PureMT -> (Int64, PureMT)
- randomWord64 :: PureMT -> (Word64, PureMT)
- randomDouble :: PureMT -> (Double, PureMT)

# The random number generator

data PureMT Source #

`PureMT`, a pure mersenne twister pseudo-random number generator

#### Instances

Instances details

Show PureMT Source # |
Instance details Defined in System.Random.Mersenne.Pure64.Internal Methods showsPrec :: Int -> PureMT -> ShowS Source # show :: PureMT -> String Source # showList :: [PureMT] -> ShowS Source #
RandomGen PureMT Source # |

Instance details

Defined in System.Random.Mersenne.Pure64

Methods

next :: PureMT -> (Int, PureMT) Source #

genWord8 :: PureMT -> (Word8, PureMT) Source #

genWord16 :: PureMT -> (Word16, PureMT) Source #

genWord32 :: PureMT -> (Word32, PureMT) Source #

genWord64 :: PureMT -> (Word64, PureMT) Source #

genWord32R :: Word32 -> PureMT -> (Word32, PureMT) Source #

genWord64R :: Word64 -> PureMT -> (Word64, PureMT) Source #

genShortByteString :: Int -> PureMT -> (ShortByteString, PureMT) Source #

genRange :: PureMT -> (Int, Int) Source #

split :: PureMT -> (PureMT, PureMT) Source #

# 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

RandomGen PureMT Source # |

Instance details

Methods

next :: PureMT -> (Int, PureMT) Source #

genWord8 :: PureMT -> (Word8, PureMT) Source #

genWord16 :: PureMT -> (Word16, PureMT) Source #

genWord32 :: PureMT -> (Word32, PureMT) Source #

genWord64 :: PureMT -> (Word64, PureMT) Source #

genWord32R :: Word32 -> PureMT -> (Word32, PureMT) Source #

genWord64R :: Word64 -> PureMT -> (Word64, PureMT) Source #

genShortByteString :: Int -> PureMT -> (ShortByteString, PureMT) Source #

genRange :: PureMT -> (Int, Int) Source #

split :: PureMT -> (PureMT, PureMT) Source #