summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libwhrandom.tex
blob: 6094462890e10138ad4b5fd9ba2a662ef776dc51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\section{Standard Module \sectcode{whrandom}}
\stmodindex{whrandom}

This module implements a Wichmann-Hill pseudo-random number generator
class that is also named \code{whrandom}.  Instances of the
\code{whrandom} class have the following methods:
\renewcommand{\indexsubitem}{(in module whrandom)}

\begin{funcdesc}{choice}{seq}
Chooses a random element from the non-empty sequence \var{seq} and returns it.
\end{funcdesc}

\begin{funcdesc}{randint}{a\, b}
Returns a random integer \var{N} such that \code{\var{a}<=\var{N}<=\var{b}}.
\end{funcdesc}

\begin{funcdesc}{random}{}
Returns the next random floating point number in the range [0.0 ... 1.0).
\end{funcdesc}

\begin{funcdesc}{seed}{x\, y\, z}
Initializes the random number generator from the integers
\var{x},
\var{y}
and
\var{z}.
When the module is first imported, the random number is initialized
using values derived from the current time.
\end{funcdesc}

\begin{funcdesc}{uniform}{a\, b}
Returns a random real number \var{N} such that \code{\var{a}<=\var{N}<\var{b}}.
\end{funcdesc}

When imported, the \code{whrandom} module also creates an instance of
the \code{whrandom} class, and makes the methods of that instance
available at the module level.  Therefore one can write either 
\code{N = whrandom.random()} or:
\begin{verbatim}
generator = whrandom.whrandom()
N = generator.random()
\end{verbatim}