annotate Doc/libwhrandom.tex @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 72986b716824
children 3468ea8645ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1471
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 \section{Standard Module \sectcode{whrandom}}
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 \stmodindex{whrandom}
5261
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
3
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
4 This module implements a Wichmann-Hill pseudo-random number generator
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
5 class that is also named \code{whrandom}. Instances of the
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
6 \code{whrandom} class have the following methods:
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
7 \renewcommand{\indexsubitem}{(in module whrandom)}
1471
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
5261
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
9 \begin{funcdesc}{choice}{seq}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
10 Chooses a random element from the non-empty sequence \var{seq} and returns it.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
11 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
12
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
13 \begin{funcdesc}{randint}{a\, b}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
14 Returns a random integer \var{N} such that \code{\var{a}<=\var{N}<=\var{b}}.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
15 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
16
1471
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 \begin{funcdesc}{random}{}
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 Returns the next random floating point number in the range [0.0 ... 1.0).
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 \end{funcdesc}
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 \begin{funcdesc}{seed}{x\, y\, z}
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 Initializes the random number generator from the integers
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 \var{x},
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 \var{y}
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 and
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 \var{z}.
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 When the module is first imported, the random number is initialized
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 using values derived from the current time.
2ec96140a36b Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 \end{funcdesc}
5261
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
30
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
31 \begin{funcdesc}{uniform}{a\, b}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
32 Returns a random real number \var{N} such that \code{\var{a}<=\var{N}<\var{b}}.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
33 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
34
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
35 When imported, the \code{whrandom} module also creates an instance of
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
36 the \code{whrandom} class, and makes the methods of that instance
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
37 available at the module level. Therefore one can write either
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
38 \code{N = whrandom.random()} or:
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
39 \begin{verbatim}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
40 generator = whrandom.whrandom()
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
41 N = generator.random()
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents: 1471
diff changeset
42 \end{verbatim}