Module Mersenne


module Mersenne: sig  end
Mersenne Twister PRNG


This is an ocaml version of the Mersenne Twister random number generator.

The interface of this pretty much follows the C reference version, except instead of using a single global seed, you can have multiple concurrent seeds that are passed to the generator functions. Thus, it can be used in multi-threaded programs as long as two threads don't use the same seed without explicit locking. It produces the same output for a given seed as the reference version, of course.



Initialization


type t 
The type of the seed pool.
val make : [< `Array of int array
| `Array32 of int32 array
| `CurrentTime
| `Seed of int
| `Seed32 of int32 ] ->
t
You can use a variety of different values for the seed when creating a new MT t, but thanks to the magic of polymorphic variants, they're all handled by the same function.


Functions returning random numbers



All of these but the int64 ones produce the same output as the reference C code.

val uint32 : t -> int32
Unsigned int32. Range: 0 <= x <= 0xffffffff
val int32 : t -> int32
Signed int32. Range: 0 <= x <= 0x7fffffff
val uint64 : t -> int64
val int64 : t -> int64
val unativeint : t -> nativeint
Unsigned nativeint.
val nativeint : t -> nativeint
Signed nativeint
val uint : t -> int
Unsigned int. Range: 0 <= x <= 0x7fffffff or 0 <= x <= 0x7fffffffffffffff
val int : t -> int
Signed int. Range: 0 <= x <= 0x3fffffff or 0 <= x <= 0x3fffffffffffffff
val real1 : t -> float
Range: 0 <= x <= 1
val real2 : t -> float
Range: 0 <= x < 1
val real3 : t -> float
Range: 0 < x < 1
val res53 : t -> float
Range: 0 <= x < 1 with 53-bit resolution
module IntSource: sig  end
Sources for use with the Rand distributions
module Int32Source: sig  end
module FloatSource: sig  end