1998-08-10 16:42:37 -03:00
|
|
|
\section{\module{whrandom} ---
|
|
|
|
Floating point pseudo-random number generator.}
|
1998-07-23 14:59:49 -03:00
|
|
|
\declaremodule{standard}{whrandom}
|
|
|
|
|
|
|
|
\modulesynopsis{Floating point pseudo-random number generator.}
|
|
|
|
|
1994-01-01 21:22:07 -04:00
|
|
|
|
1997-04-03 18:41:49 -04:00
|
|
|
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:
|
|
|
|
|
|
|
|
\begin{funcdesc}{choice}{seq}
|
|
|
|
Chooses a random element from the non-empty sequence \var{seq} and returns it.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 02:33:25 -04:00
|
|
|
\begin{funcdesc}{randint}{a, b}
|
1997-04-03 18:41:49 -04:00
|
|
|
Returns a random integer \var{N} such that \code{\var{a}<=\var{N}<=\var{b}}.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1994-01-01 21:22:07 -04:00
|
|
|
\begin{funcdesc}{random}{}
|
|
|
|
Returns the next random floating point number in the range [0.0 ... 1.0).
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1998-03-17 02:33:25 -04:00
|
|
|
\begin{funcdesc}{seed}{x, y, z}
|
1999-11-10 12:21:37 -04:00
|
|
|
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.
|
1994-01-01 21:22:07 -04:00
|
|
|
\end{funcdesc}
|
1997-04-03 18:41:49 -04:00
|
|
|
|
1998-03-17 02:33:25 -04:00
|
|
|
\begin{funcdesc}{uniform}{a, b}
|
1997-04-03 18:41:49 -04:00
|
|
|
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:
|
1998-02-13 02:58:54 -04:00
|
|
|
\begin{verbatim}
|
1997-04-03 18:41:49 -04:00
|
|
|
generator = whrandom.whrandom()
|
|
|
|
N = generator.random()
|
1998-02-13 02:58:54 -04:00
|
|
|
\end{verbatim}
|
1999-11-10 12:21:37 -04:00
|
|
|
|
1997-07-17 13:34:52 -03:00
|
|
|
\begin{seealso}
|
1999-11-10 12:21:37 -04:00
|
|
|
\seemodule{random}{generators for various random distributions}
|
|
|
|
\seetext{Wichmann, B. A. \& Hill, I. D., ``Algorithm AS 183:
|
|
|
|
An efficient and portable pseudo-random number generator'',
|
|
|
|
\citetitle{Applied Statistics} 31 (1982) 188-190.}
|
1997-07-17 13:34:52 -03:00
|
|
|
\end{seealso}
|