Changeset 391 for python/trunk/Doc/library/random.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/random.rst
r2 r391 1 2 1 :mod:`random` --- Generate pseudo-random numbers 3 2 ================================================ … … 6 5 :synopsis: Generate pseudo-random numbers with various common distributions. 7 6 7 **Source code:** :source:`Lib/random.py` 8 9 -------------- 8 10 9 11 This module implements pseudo-random number generators for various … … 53 55 54 56 .. versionchanged:: 2.3 55 Substituted MersenneTwister for Wichmann-Hill. 57 MersenneTwister replaced Wichmann-Hill as the default generator. 58 59 The :mod:`random` module also provides the :class:`SystemRandom` class which 60 uses the system function :func:`os.urandom` to generate random numbers 61 from sources provided by the operating system. 62 63 .. warning:: 64 65 The pseudo-random generators of this module should not be used for 66 security purposes. Use :func:`os.urandom` or :class:`SystemRandom` if 67 you require a cryptographically secure pseudo-random number generator. 68 56 69 57 70 Bookkeeping functions: … … 70 83 formerly, operating system resources were not used. 71 84 72 If *x* is not ``None`` or an int or long, ``hash(x)`` is used instead. If *x* is73 an int or long, *x* is used directly.74 75 76 85 .. function:: getstate() 77 86 … … 89 98 *state* should have been obtained from a previous call to :func:`getstate`, and 90 99 :func:`setstate` restores the internal state of the generator to what it was at 91 the time :func:` setstate` was called.100 the time :func:`getstate` was called. 92 101 93 102 .. versionadded:: 2.1 … … 123 132 124 133 125 .. function:: randrange([start,] stop[, step]) 134 .. function:: randrange(stop) 135 randrange(start, stop[, step]) 126 136 127 137 Return a randomly selected element from ``range(start, stop, step)``. This is … … 195 205 depending on floating-point rounding in the equation ``a + (b-a) * random()``. 196 206 207 197 208 .. function:: triangular(low, high, mode) 198 209 … … 224 235 Gamma distribution. (*Not* the gamma function!) Conditions on the 225 236 parameters are ``alpha > 0`` and ``beta > 0``. 237 238 The probability distribution function is:: 239 240 x ** (alpha - 1) * math.exp(-x / beta) 241 pdf(x) = -------------------------------------- 242 math.gamma(alpha) * beta ** alpha 226 243 227 244
Note:
See TracChangeset
for help on using the changeset viewer.