1Random(3)                        OCaml library                       Random(3)
2
3
4

NAME

6       Random - Pseudo-random number generators (PRNG).
7

Module

9       Module   Random
10

Documentation

12       Module Random
13        : sig end
14
15
16       Pseudo-random number generators (PRNG).
17
18
19
20
21
22
23
24   Basic functions
25       val init : int -> unit
26
27       Initialize  the generator, using the argument as a seed.  The same seed
28       will always yield the same sequence of numbers.
29
30
31
32       val full_init : int array -> unit
33
34       Same as Random.init but takes more data as seed.
35
36
37
38       val self_init : unit -> unit
39
40       Initialize the generator with a random seed chosen in  a  system-depen‐
41       dent way.  If /dev/urandom is available on the host machine, it is used
42       to provide a highly random initial seed.  Otherwise, a less random seed
43       is computed from system parameters (current time, process IDs).
44
45
46
47       val bits : unit -> int
48
49       Return 30 random bits in a nonnegative integer.
50
51
52       Before3.12.0  used  a  different  algorithm  (affects all the following
53       functions)
54
55
56
57
58       val int : int -> int
59
60
61       Random.int bound returns a random integer  between  0  (inclusive)  and
62       bound (exclusive).  bound must be greater than 0 and less than 2^30.
63
64
65
66       val int32 : Int32.t -> Int32.t
67
68
69       Random.int32  bound  returns a random integer between 0 (inclusive) and
70       bound (exclusive).  bound must be greater than 0.
71
72
73
74       val nativeint : Nativeint.t -> Nativeint.t
75
76
77       Random.nativeint bound returns a random integer between  0  (inclusive)
78       and bound (exclusive).  bound must be greater than 0.
79
80
81
82       val int64 : Int64.t -> Int64.t
83
84
85       Random.int64  bound  returns a random integer between 0 (inclusive) and
86       bound (exclusive).  bound must be greater than 0.
87
88
89
90       val float : float -> float
91
92
93       Random.float bound returns a random floating-point number between 0 and
94       bound  (inclusive).   If  bound  is negative, the result is negative or
95       zero.  If bound is 0, the result is 0.
96
97
98
99       val bool : unit -> bool
100
101
102       Random.bool () returns true or false with probability 0.5 each.
103
104
105
106
107   Advanced functions
108       The functions from module Random.State manipulate the current state  of
109       the  random generator explicitly.  This allows using one or several de‐
110       terministic PRNGs, even in a multi-threaded program, without  interfer‐
111       ence from other parts of the program.
112
113       module State : sig end
114
115
116
117
118
119       val get_state : unit -> State.t
120
121       Return the current state of the generator used by the basic functions.
122
123
124
125       val set_state : State.t -> unit
126
127       Set the state of the generator used by the basic functions.
128
129
130
131
132
133OCamldoc                          2021-01-26                         Random(3)
Impressum