Next: 1.14 Scanning in Prolog
Up: 1. Library Utilities
Previous: 1.12 Gensym
Contents
Index
The following predicates are provided in module random to
generate random numbers (both integers and floating numbers), based on
the Wichmann-Hill Algorithm [22,16]. The random number
generator is entirely portable, and does not require any calls to the
operating system. As noted below, it does require 3 seeds, each of
which must be an integer in a given range. These seeds are
thread-specific: thus different threads may generate independent
sequences of random numbers.
- random(-Number)
- random
Binds Number to a random float in the interval [0.0, 1.0).
Note that 1.0 will never be generated.
- random(+Lower,+Upper,-Number)
- random
Binds Number to a random integer in the interval
[Lower,Upper) if Lower and Upper
are integers. Otherwise Number is bound to a random float
between Lower and Upper. Upper will
never be generated.
- getrand(?State)
- random
Tries to unify State with the term rand(X,Y,Z)
where X,Y,and Z are integers describing
the state of the random generator.
- setrand(rand(+X,+Y,+Z))
- random
Sets the state of the random generator. X,Y, and
Z must be integers in the ranges [1,30269), [1,30307),
[1,30323), respectively.
- datime_setrand
- random
This simple initialization utility sets the random seed triple based on a
function of the current day, hour, minute and second.
- randseq(+K, +N, -RandomSeq)
- random
Generates a sequence of K unique integers chosen randomly
in the range from 1 to N. RandomSeq is not
returned in any particular order.
- randset(+K, +N, -RandomSet)
- random
Generates an ordered set of K unique integers chosen
randomly in the range from 1 to N. The set is returned in
reversed order, with the largest element first and the smallest
last.
Next: 1.14 Scanning in Prolog
Up: 1. Library Utilities
Previous: 1.12 Gensym
Contents
Index
Terrance Swift
2007-10-06