Bump version to 0.9.1.
[python/dscho.git] / Doc / lib / libwhrandom.tex
blobb745f5bc055ac39121ec9a5b2a9f83b8154a1a81
1 \section{\module{whrandom} ---
2 Pseudo-random number generator}
4 \declaremodule{standard}{whrandom}
5 \modulesynopsis{Floating point pseudo-random number generator.}
8 This module implements a Wichmann-Hill pseudo-random number generator
9 class that is also named \class{whrandom}. Instances of the
10 \class{whrandom} class conform to the Random Number Generator
11 interface described in section \ref{rng-objects}. They also offer the
12 following method, specific to the Wichmann-Hill algorithm:
14 \begin{methoddesc}[whrandom]{seed}{\optional{x, y, z}}
15 Initializes the random number generator from the integers \var{x},
16 \var{y} and \var{z}. When the module is first imported, the random
17 number is initialized using values derived from the current time.
18 If \var{x}, \var{y}, and \var{z} are either omitted or \code{0}, the
19 seed will be computed from the current system time. If one or two
20 of the parameters are \code{0}, but not all three, the zero values
21 are replaced by ones. This causes some apparently different seeds
22 to be equal, with the corresponding result on the pseudo-random
23 series produced by the generator.
24 \end{methoddesc}
26 \begin{funcdesc}{choice}{seq}
27 Chooses a random element from the non-empty sequence \var{seq} and returns it.
28 \end{funcdesc}
30 \begin{funcdesc}{randint}{a, b}
31 Returns a random integer \var{N} such that \code{\var{a}<=\var{N}<=\var{b}}.
32 \end{funcdesc}
34 \begin{funcdesc}{random}{}
35 Returns the next random floating point number in the range [0.0 ... 1.0).
36 \end{funcdesc}
38 \begin{funcdesc}{seed}{x, y, z}
39 Initializes the random number generator from the integers \var{x},
40 \var{y} and \var{z}. When the module is first imported, the random
41 number is initialized using values derived from the current time.
42 \end{funcdesc}
44 \begin{funcdesc}{uniform}{a, b}
45 Returns a random real number \var{N} such that \code{\var{a}<=\var{N}<\var{b}}.
46 \end{funcdesc}
48 When imported, the \module{whrandom} module also creates an instance of
49 the \class{whrandom} class, and makes the methods of that instance
50 available at the module level. Therefore one can write either
51 \code{N = whrandom.random()} or:
53 \begin{verbatim}
54 generator = whrandom.whrandom()
55 N = generator.random()
56 \end{verbatim}
58 Note that using separate instances of the generator leads to
59 independent sequences of pseudo-random numbers.
61 \begin{seealso}
62 \seemodule{random}{Generators for various random distributions and
63 documentation for the Random Number Generator
64 interface.}
65 \seetext{Wichmann, B. A. \& Hill, I. D., ``Algorithm AS 183:
66 An efficient and portable pseudo-random number generator'',
67 \citetitle{Applied Statistics} 31 (1982) 188-190.}
68 \end{seealso}