Module Mt19937ar

module Mt19937ar: sig .. end

Mersenne Twister pseudorandom number generator, with the period 2^19937 - 1 in 32 bit units.


Generator

type t 

The type of the state.

Initialization

val make_int32 : int32 -> t
val make_int32_array : int32 array -> t
val make : int array -> t
val make_self_init : unit -> t
val copy : t -> t

Bit generation

val bits31 : t -> int

Draws out 31 bits of higher part of 32 bits. It calls genrand_int31.

val bits32 : t -> int32

Draws out 32 bits. It calls genrand_int32.

val bits64 : t -> int64

Draws out 64 bits. The result is composed by drawing out 32 bit twice, first for the lower bits and then for upper bits, with Mt19937ar.bits32.

val float_bits32 : t -> float

Draws out 32 bits as float [0,1). It calls genrand_real2.

Uniform distribution

val int : t -> int -> int

[0,bound). Draws out values repeatedly as needed in 32 bit units if the bound fits into 32 bits otherwise 64 bit units.

val int32 : t -> int32 -> int32
val int64 : t -> int64 -> int64
val nativeint : t -> nativeint -> nativeint
val float : t -> float -> float

[0,bound), unlike Stdlib.Random.float. Draws out 64 bits once.

val bool : t -> bool

false or true. Draws out 32 bits once.

Serialization

val import : int32 array * int -> t
val export : t -> int32 array * int