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