Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libwhrandom.tex @ 21467:4e35fa5d5708 legacy-trunk
Add documentation for the help() built-in; contributed by Ka-Ping Yee.
This is part of SF patch #494622.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 18 Dec 2001 16:31:08 +0000 |
| parents | 376ee174ecd0 |
| children | afe90e9e4b48 |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{whrandom} --- |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
2 Pseudo-random number generator} |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
3 |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
4 \declaremodule{standard}{whrandom} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
5 \modulesynopsis{Floating point pseudo-random number generator.} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
6 |
|
16440
7a39704a5047
Revise the deprecation note for the whrandom module to be correct and a
Fred Drake <fdrake@acm.org>
parents:
16403
diff
changeset
|
7 \deprecated{2.1}{Use \refmodule{random} instead.} |
|
7a39704a5047
Revise the deprecation note for the whrandom module to be correct and a
Fred Drake <fdrake@acm.org>
parents:
16403
diff
changeset
|
8 |
|
20580
376ee174ecd0
Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents:
16440
diff
changeset
|
9 \note{This module was an implementation detail of the |
|
16440
7a39704a5047
Revise the deprecation note for the whrandom module to be correct and a
Fred Drake <fdrake@acm.org>
parents:
16403
diff
changeset
|
10 \refmodule{random} module in releases of Python prior to 2.1. It is |
|
7a39704a5047
Revise the deprecation note for the whrandom module to be correct and a
Fred Drake <fdrake@acm.org>
parents:
16403
diff
changeset
|
11 no longer used. Please do not use this module directly; use |
|
20580
376ee174ecd0
Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents:
16440
diff
changeset
|
12 \refmodule{random} instead.} |
| 5261 | 13 |
| 14 This module implements a Wichmann-Hill pseudo-random number generator | |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
15 class that is also named \class{whrandom}. Instances of the |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
16 \class{whrandom} class conform to the Random Number Generator |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
17 interface described in section \ref{rng-objects}. They also offer the |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
18 following method, specific to the Wichmann-Hill algorithm: |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
19 |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
20 \begin{methoddesc}[whrandom]{seed}{\optional{x, y, z}} |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
21 Initializes the random number generator from the integers \var{x}, |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
22 \var{y} and \var{z}. When the module is first imported, the random |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
23 number is initialized using values derived from the current time. |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
24 If \var{x}, \var{y}, and \var{z} are either omitted or \code{0}, the |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
25 seed will be computed from the current system time. If one or two |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
26 of the parameters are \code{0}, but not all three, the zero values |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
27 are replaced by ones. This causes some apparently different seeds |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
28 to be equal, with the corresponding result on the pseudo-random |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
29 series produced by the generator. |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
30 \end{methoddesc} |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
| 5261 | 32 \begin{funcdesc}{choice}{seq} |
| 33 Chooses a random element from the non-empty sequence \var{seq} and returns it. | |
| 34 \end{funcdesc} | |
| 35 | |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7614
diff
changeset
|
36 \begin{funcdesc}{randint}{a, b} |
| 5261 | 37 Returns a random integer \var{N} such that \code{\var{a}<=\var{N}<=\var{b}}. |
| 38 \end{funcdesc} | |
| 39 | |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 \begin{funcdesc}{random}{} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 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
|
42 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7614
diff
changeset
|
44 \begin{funcdesc}{seed}{x, y, z} |
|
11463
17e12305973e
Use \citetitle and \programopt as appropriate.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
45 Initializes the random number generator from the integers \var{x}, |
|
17e12305973e
Use \citetitle and \programopt as appropriate.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
46 \var{y} and \var{z}. When the module is first imported, the random |
|
17e12305973e
Use \citetitle and \programopt as appropriate.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
47 number is initialized using values derived from the current time. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 \end{funcdesc} |
| 5261 | 49 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7614
diff
changeset
|
50 \begin{funcdesc}{uniform}{a, b} |
| 5261 | 51 Returns a random real number \var{N} such that \code{\var{a}<=\var{N}<\var{b}}. |
| 52 \end{funcdesc} | |
| 53 | |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
54 When imported, the \module{whrandom} module also creates an instance of |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
55 the \class{whrandom} class, and makes the methods of that instance |
| 5261 | 56 available at the module level. Therefore one can write either |
| 57 \code{N = whrandom.random()} or: | |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
58 |
|
7277
bf4e790bd61a
Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents:
5818
diff
changeset
|
59 \begin{verbatim} |
| 5261 | 60 generator = whrandom.whrandom() |
| 61 N = generator.random() | |
|
7277
bf4e790bd61a
Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents:
5818
diff
changeset
|
62 \end{verbatim} |
|
11463
17e12305973e
Use \citetitle and \programopt as appropriate.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
63 |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
64 Note that using separate instances of the generator leads to |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
65 independent sequences of pseudo-random numbers. |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
66 |
| 5818 | 67 \begin{seealso} |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
68 \seemodule{random}{Generators for various random distributions and |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
69 documentation for the Random Number Generator |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
11463
diff
changeset
|
70 interface.} |
|
11463
17e12305973e
Use \citetitle and \programopt as appropriate.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
71 \seetext{Wichmann, B. A. \& Hill, I. D., ``Algorithm AS 183: |
|
17e12305973e
Use \citetitle and \programopt as appropriate.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
72 An efficient and portable pseudo-random number generator'', |
|
17e12305973e
Use \citetitle and \programopt as appropriate.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
73 \citetitle{Applied Statistics} 31 (1982) 188-190.} |
| 5818 | 74 \end{seealso} |
