summaryrefslogtreecommitdiff
path: root/doc/source/reference/random/index.rst
diff options
context:
space:
mode:
authorKevin Sheppard <kevin.k.sheppard@gmail.com>2019-04-16 07:22:22 +0100
committermattip <matti.picus@gmail.com>2019-05-20 18:53:28 +0300
commitdd77ce3cb84986308986974acfe988575323f75a (patch)
tree7c6378ef941f3d9fa4a6bb63e034aa600b98c6c5 /doc/source/reference/random/index.rst
parentca9c542d24d418b4a203255f3a390c6b7fee4b51 (diff)
downloadnumpy-dd77ce3cb84986308986974acfe988575323f75a.tar.gz
ENH: Add closed generator to randint
Add closed option to randint to simplify some cases
Diffstat (limited to 'doc/source/reference/random/index.rst')
-rw-r--r--doc/source/reference/random/index.rst66
1 files changed, 2 insertions, 64 deletions
diff --git a/doc/source/reference/random/index.rst b/doc/source/reference/random/index.rst
index 701415920..9c8c99c38 100644
--- a/doc/source/reference/random/index.rst
+++ b/doc/source/reference/random/index.rst
@@ -1,14 +1,10 @@
+.. _numpyrandom:
+
.. currentmodule:: numpy.random
numpy.random
============
-<<<<<<< HEAD
-A `~RandomGenerator` can
-be initialized with a number of different Random Number Generators (RNG)s, and
-exposes many different probability distributions.
-
-=======
Numpy's random number routines produce psuedo random numbers using
combinations of a `BitGenerator` to create sequences and a `Generator`
to use those sequences to sample from different statistical distributions:
@@ -30,19 +26,12 @@ available, but limited to a single BitGenerator.
For convenience and backward compatibility, a single `RandomState`
instance's methods are imported into the numpy.random namespace, see
:ref:`legacy` for the complete list.
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
Quick Start
-----------
-<<<<<<< HEAD
-By default, `RandomGenerator` uses normals provided by
-`xoroshiro128.Xoroshiro128` which will be faster than the legacy methods in
-`mtrand.RandomState`
-=======
By default, `Generator` uses normals provided by `xoroshiro128.Xoroshiro128`
which will be faster than the legacy methods in `RandomState`
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
.. code-block:: python
@@ -50,17 +39,10 @@ which will be faster than the legacy methods in `RandomState`
from numpy import random
random.standard_normal()
-<<<<<<< HEAD
-`RandomGenerator` can be used as a direct replacement for
-`~RandomState`, although the random values are generated by
-`~xoroshiro128.Xoroshiro128`. The `RandomGenerator` holds an instance of a RNG.
-It is accessable as ``gen.brng``.
-=======
`Generator` can be used as a direct replacement for `RandomState`,
although the random values are generated by `~xoroshiro128.Xoroshiro128`. The
`Generator` holds an instance of a BitGenerator. It is accessable as
``gen.bit_generator``.
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
.. code-block:: python
@@ -85,49 +67,23 @@ generator`.
Introduction
------------
RandomGen takes a different approach to producing random numbers from the
-<<<<<<< HEAD
-:class:`numpy.random.RandomState` object. Random number generation is
-separated into two components, a basic RNG and a random generator.
-=======
`RandomState` object. Random number generation is separated into two
components, a bit generator and a random generator.
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
The basic RNG has a limited set of responsibilities. It manages the
underlying RNG state and provides functions to produce random doubles and
random unsigned 32- and 64-bit values. The basic random generator also handles
all seeding since this varies when using alternative basic RNGs.
-<<<<<<< HEAD
-The `random generator <~RandomGenerator>` takes the
-basic RNG-provided functions and transforms them into more useful
-=======
The `random generator <Generator>` takes the
bit generator-provided stream and transforms them into more useful
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
distributions, e.g., simulated normal random values. This structure allows
alternative basic RNGs to be used without code duplication.
-<<<<<<< HEAD
-The ``RandomGenerator`` is the user-facing object
-that is nearly identical to :class:`~.RandomState`. The canonical
-method to initialize a generator passes a basic RNG -- `~mt19937.MT19937`, the
-underlying RNG in NumPy -- as the sole argument. Note that the basic RNG must
-be instantized.
-
-.. code-block:: python
-
- from numpy.random import RandomGenerator, MT19937
- rg = RandomGenerator(MT19937())
- rg.random_sample()
-
-Seed information is directly passed to the basic RNG.
-=======
The `Generator` is the user-facing object that is nearly identical to
`RandomState`. The canonical method to initialize a generator passes a
`~mt19937.MT19937` bit generator, the underlying bit generator in Python -- as
the sole argument. Note that the bit generator must be instantiated.
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
.. code-block:: python
@@ -147,13 +103,8 @@ What's New or Different
.. warning::
The Box-Muller method used to produce NumPy's normals is no longer available
-<<<<<<< HEAD
- in `~.RandomGenerator`. It is not possible to reproduce the exact random
- values using ``RandomGenerator`` for the normal distribution or any other
-=======
in `Generator`. It is not possible to reproduce the exact random
values using Generator for the normal distribution or any other
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
distribution that relies on the normal such as the `numpy.random.gamma` or
`numpy.random.standard_t`. If you require bitwise backward compatible
streams, use `RandomState`.
@@ -169,17 +120,6 @@ What's New or Different
* `~entropy.random_entropy` provides access to the system
source of randomness that is used in cryptographic applications (e.g.,
``/dev/urandom`` on Unix).
-<<<<<<< HEAD
-* All basic random generators functions can produce doubles, uint64s and
- uint32s via CTypes (`~xoroshiro128.Xoroshiro128.ctypes`)
- and CFFI (:meth:`~xoroshiro128.Xoroshiro128.cffi`).
- This allows these basic RNGs to be used in numba.
-* The basic random number generators can be used in downstream projects via
- :ref:`Cython <randomgen_cython>`.
-* Support for Lemire’s method [Lemire]_ of generating uniform integers on an
- arbitrary interval by setting ``use_masked=True`` in
- `~RandomGenerator.randint`.
-=======
* All BitGenerators can produce doubles, uint64s and uint32s via CTypes
(`~xoroshiro128.Xoroshiro128.ctypes`) and CFFI
(:meth:`~xoroshiro128.Xoroshiro128.cffi`). This allows the bit generators to
@@ -195,8 +135,6 @@ What's New or Different
random numbers, which replaces `random_sample`, `sample`, and `ranf`. This
is consistent with Python's `random.random`.
->>>>>>> d7650d9f2... DOC: use more BitGenerator instead of other termonology
-
See :ref:`new-or-different` for a complete list of improvements and
differences.