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

NAME

6       Stdlib.Random - no description
7

Module

9       Module   Stdlib.Random
10

Documentation

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