1995-10-16 05:40:46 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-10-16 05:40:46 -07:00
|
|
|
(* *)
|
|
|
|
(* Damien Doligez, projet Para, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
2001-12-07 05:41:02 -08:00
|
|
|
(* under the terms of the GNU Library General Public License, with *)
|
|
|
|
(* the special exception on linking described in file ../LICENSE. *)
|
1995-10-16 05:40:46 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
2001-10-26 15:38:48 -07:00
|
|
|
(** Pseudo-random number generator (PRNG). *)
|
1995-10-16 05:40:46 -07:00
|
|
|
|
2001-12-03 14:16:03 -08:00
|
|
|
val init : int -> unit
|
2001-10-26 15:38:48 -07:00
|
|
|
(** Initialize the generator, using the argument as a seed.
|
1995-10-16 05:40:46 -07:00
|
|
|
The same seed will always yield the same sequence of numbers. *)
|
2001-10-26 15:38:48 -07:00
|
|
|
|
1995-10-16 05:40:46 -07:00
|
|
|
val full_init : int array -> unit
|
2001-12-03 14:16:03 -08:00
|
|
|
(** Same as {!Random.init} but takes more data as seed. *)
|
2001-10-26 15:38:48 -07:00
|
|
|
|
2001-12-03 14:16:03 -08:00
|
|
|
val self_init : unit -> unit
|
2001-10-26 15:38:48 -07:00
|
|
|
(** Initialize the generator with a more-or-less random seed chosen
|
|
|
|
in a system-dependent way. *)
|
1995-10-16 05:40:46 -07:00
|
|
|
|
1996-11-06 08:54:46 -08:00
|
|
|
val bits : unit -> int
|
2001-12-03 14:16:03 -08:00
|
|
|
(** Return 30 random bits in a nonnegative integer. *)
|
2001-10-26 15:38:48 -07:00
|
|
|
|
2001-12-03 14:16:03 -08:00
|
|
|
val int : int -> int
|
2001-10-26 15:38:48 -07:00
|
|
|
(** [Random.int bound] returns a random integer between 0 (inclusive)
|
1997-03-31 07:51:43 -08:00
|
|
|
and [bound] (exclusive). [bound] must be more than 0 and less
|
2001-10-29 09:58:08 -08:00
|
|
|
than 2{^30}. *)
|
2001-10-26 15:38:48 -07:00
|
|
|
|
2001-12-03 14:16:03 -08:00
|
|
|
val float : float -> float
|
2001-10-26 15:38:48 -07:00
|
|
|
(** [Random.float bound] returns a random floating-point number
|
|
|
|
between 0 (inclusive) and [bound] (exclusive). If [bound] is
|
|
|
|
negative, the result is negative. If [bound] is 0, the result
|
|
|
|
is 0. *)
|
2000-11-20 06:20:03 -08:00
|
|
|
|
2001-12-03 14:16:03 -08:00
|
|
|
type state
|
2001-10-26 15:38:48 -07:00
|
|
|
(** Values of this type are used to store the current state of the
|
|
|
|
generator. *)
|
|
|
|
|
2001-12-03 14:16:03 -08:00
|
|
|
val get_state : unit -> state
|
2001-10-26 15:38:48 -07:00
|
|
|
(** Returns the current state of the generator. This is useful for
|
|
|
|
checkpointing computations that use the PRNG. *)
|
|
|
|
|
2001-12-03 14:16:03 -08:00
|
|
|
val set_state : state -> unit
|
2001-10-26 15:38:48 -07:00
|
|
|
(** Resets the state of the generator to some previous state returned by
|
|
|
|
{!Random.get_state}. *)
|
|
|
|
|