Module BC_Random


module BC_Random: sig  end
Random stuff :P.

The random number generators use the MT(Mersenne Twister) algorithm written in C.
See also MT home page


val int : int -> int
returns a random integer between 0 (inclusive) and `bound' (exclusive). `bound' must be more than 0 and I'm not sure about the maximum ....
val float : float -> float
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.
val sgenrandint : int -> unit
set seed (!= 0) for random integer generator
val genrandint : unit -> int
generate random integer
val sgenrand : int -> unit
set seed (!=0) for float integer generator
val genrand : unit -> float
generate random float
val sample_array : int -> 'a array -> 'a array
sample_array k a randomly selects k elements from array a of n elements (Floyd's Algorithm?).
Raises Invalid_argument when k > n
val sample_list : int -> 'a list -> 'a list
sample_list k l randomly selects k elements from list l of n elements (Floyd's Algorithm?).
Raises Invalid_argument when k > n
val cross_sample_list : int -> 'a list -> ('a list * 'a list) list
cross_sample_list k l randomly divides the list l into k lists (s_{0} .. s_{k-1}) of (almost) equal size, and returns the list of pairs: (s_{i}, l - s_{i}) for i = 0 .. k-1. The number of elements in each of the k sets is: k_{0} : n/k + (n mod k), and k_1, ..., k_{k-1} : n/k where n is the length of l.
val sample : int -> int -> int list
sample k n randomly selects k integers from the set : {0, 1, ..., n-1}.
Raises Invalid_argument when k > n
val cross_sample : int -> int -> (int list * int list) list
cross_sample k n randomly divides the set : {0, 1, ..., n-1} into k sets (s_{0} .. s_{k-1}) of (almost) equal size and returns list of pairs: (s_{i}, n - s_{i}) for i = 0 .. k-1. The number of elements in each of the k sets is: k_{0} : n/k + (n mod k), and k_1, ..., k_{k-1} : n/k