Module Gsl.Rng

Random Number Generation

type rng_type =
  1. | BOROSH13
  2. | COVEYOU
  3. | CMRG
  4. | FISHMAN18
  5. | FISHMAN20
  6. | FISHMAN2X
  7. | GFSR4
  8. | KNUTHRAN
  9. | KNUTHRAN2
  10. | KNUTHRAN2002
  11. | LECUYER21
  12. | MINSTD
  13. | MRG
  14. | MT19937
  15. | MT19937_1999
  16. | MT19937_1998
  17. | R250
  18. | RAN0
  19. | RAN1
  20. | RAN2
  21. | RAN3
  22. | RAND
  23. | RAND48
  24. | RANDOM128_BSD
  25. | RANDOM128_GLIBC2
  26. | RANDOM128_LIBC5
  27. | RANDOM256_BSD
  28. | RANDOM256_GLIBC2
  29. | RANDOM256_LIBC5
  30. | RANDOM32_BSD
  31. | RANDOM32_GLIBC2
  32. | RANDOM32_LIBC5
  33. | RANDOM64_BSD
  34. | RANDOM64_GLIBC2
  35. | RANDOM64_LIBC5
  36. | RANDOM8_BSD
  37. | RANDOM8_GLIBC2
  38. | RANDOM8_LIBC5
  39. | RANDOM_BSD
  40. | RANDOM_GLIBC2
  41. | RANDOM_LIBC5
  42. | RANDU
  43. | RANF
  44. | RANLUX
  45. | RANLUX389
  46. | RANLXD1
  47. | RANLXD2
  48. | RANLXS0
  49. | RANLXS1
  50. | RANLXS2
  51. | RANMAR
  52. | SLATEC
  53. | TAUS
  54. | TAUS_2
  55. | TAUS_113
  56. | TRANSPUTER
  57. | TT800
  58. | UNI
  59. | UNI32
  60. | VAX
  61. | WATERMAN14
  62. | ZUF
type t

Default values

val default : unit -> rng_type
val default_seed : unit -> nativeint
val set_default : rng_type -> unit
val set_default_seed : nativeint -> unit
val env_setup : unit -> unit

Creating

val make : rng_type -> t
val set : t -> nativeint -> unit
val name : t -> string
val get_type : t -> rng_type

warning : the nativeint used for seeds are in fact unsigned but ocaml treats them as signed. But you can still print them using %nu with printf functions.

val max : t -> nativeint
val min : t -> nativeint
val memcpy : t -> t -> unit
val clone : t -> t
val dump_state : t -> string * string
val set_state : t -> (string * string) -> unit

Sampling

val get : t -> nativeint
val uniform : t -> float
val uniform_pos : t -> float
val uniform_int : t -> int -> int

These function fill the array with random numbers :

val uniform_arr : t -> float array -> unit
val uniform_pos_arr : t -> float array -> unit