annotate Doc/librandom.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
5261
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 \section{Standard Module \sectcode{random}}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 \stmodindex{random}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 This module implements pseudo-random number generators for various
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 distributions: on the real line, there are functions to compute normal
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 or Gaussian, lognormal, negative exponential, gamma, and beta
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 distributions. For generating distribution of angles, the circular
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 uniform and von Mises distributions are available.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 The module exports the following functions, which are exactly
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 equivalent to those in the \code{whrandom} module: \code{choice},
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 \code{randint}, \code{random}, \code{uniform}. See the documentation
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 for the \code{whrandom} module for these functions.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 The following functions specific to the \code{random} module are also
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 defined, and all return real values. Function parameters are named
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 after the corresponding variables in the distribution's equation, as
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 used in common mathematical practice; most of these equations can be
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 found in any statistics text.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 \renewcommand{\indexsubitem}{(in module random)}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 \begin{funcdesc}{betavariate}{alpha\, beta}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 Beta distribution. Conditions on the parameters are \code{alpha>-1}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 and \code{beta>-1}.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 Returned values will range between 0 and 1.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 \begin{funcdesc}{cunifvariate}{mean\, arc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 Circular uniform distribution. \var{mean} is the mean angle, and
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 \var{arc} is the range of the distribution, centered around the mean
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 angle. Both values must be expressed in radians, and can range
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 between 0 and \code{pi}. Returned values will range between
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 \code{mean - arc/2} and \code{mean + arc/2}.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 \begin{funcdesc}{expovariate}{lambd}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 Exponential distribution. \var{lambd} is 1.0 divided by the desired mean.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 (The parameter would be called ``lambda'', but that's also a reserved
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 word in Python.) Returned values will range from 0 to positive infinity.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
41
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 \begin{funcdesc}{gamma}{alpha\, beta}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 Gamma distribution. (\emph{Not} the gamma function!)
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 Conditions on the parameters are \code{alpha>-1} and \code{beta>0}.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 \begin{funcdesc}{gauss}{mu\, sigma}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 Gaussian distribution. \var{mu} is the mean, and \var{sigma} is the
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 standard deviation. This is slightly faster than the
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 \code{normalvariate} function defined below.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
52
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 \begin{funcdesc}{lognormvariate}{mu\, sigma}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 Log normal distribution. If you take the natural logarithm of this
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 distribution, you'll get a normal distribution with mean \var{mu} and
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 standard deviation \var{sigma} \var{mu} can have any value, and \var{sigma}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 must be greater than zero.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
59
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 \begin{funcdesc}{normalvariate}{mu\, sigma}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 Normal distribution. \var{mu} is the mean, and \var{sigma} is the
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 standard deviation.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 \end{funcdesc}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 \begin{funcdesc}{vonmisesvariate}{mu\, kappa}
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 \var{mu} is the mean angle, expressed in radians between 0 and pi,
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 and \var{kappa} is the concentration parameter, which must be greater
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 then or equal to zero. If \var{kappa} is equal to zero, this
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 distribution reduces to a uniform random angle over the range 0 to
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 \code{2*pi}.
72986b716824 New stuff by AMK.
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 \end{funcdesc}