cpython-withatomic / Doc / libwhrandom.tex

The branch 'legacy-trunk' does not exist.
\section{Standard Module \sectcode{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)}

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

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

Returns the next random floating point number in the range [0.0 ... 1.0).

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

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

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:
generator = whrandom.whrandom()
N = generator.random()
\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'', 
Applied Statistics 31 (1982) 188-190}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.