summaryrefslogtreecommitdiff
path: root/doc
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
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')
-rw-r--r--doc/source/about.rst2
-rw-r--r--doc/source/conf.py4
-rw-r--r--doc/source/reference/random/index.rst66
-rw-r--r--doc/source/reference/routines.random.rst83
-rw-r--r--doc/source/reference/routines.rst1
5 files changed, 3 insertions, 153 deletions
diff --git a/doc/source/about.rst b/doc/source/about.rst
index 5ac4facbb..3e83833d1 100644
--- a/doc/source/about.rst
+++ b/doc/source/about.rst
@@ -8,7 +8,7 @@ needed for scientific computing with Python. This package contains:
- sophisticated :ref:`(broadcasting) functions <ufuncs>`
- basic :ref:`linear algebra functions <routines.linalg>`
- basic :ref:`Fourier transforms <routines.fft>`
-- sophisticated :ref:`random number capabilities <routines.random>`
+- sophisticated :ref:`random number capabilities <numpyrandom>`
- tools for integrating Fortran code
- tools for integrating C/C++ code
diff --git a/doc/source/conf.py b/doc/source/conf.py
index dec8fff05..906a906b6 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -364,7 +364,3 @@ def linkcode_resolve(domain, info):
return "https://github.com/numpy/numpy/blob/v%s/numpy/%s%s" % (
numpy.__version__, fn, linespec)
-doctest_global_setup = '''
-import numpy as np
-from numpy.random import randomgen
-'''
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.
diff --git a/doc/source/reference/routines.random.rst b/doc/source/reference/routines.random.rst
deleted file mode 100644
index cda4e2b61..000000000
--- a/doc/source/reference/routines.random.rst
+++ /dev/null
@@ -1,83 +0,0 @@
-.. _routines.random:
-
-.. module:: numpy.random
-
-Random sampling (:mod:`numpy.random`)
-*************************************
-
-.. currentmodule:: numpy.random
-
-Simple random data
-==================
-.. autosummary::
- :toctree: generated/
-
- rand
- randn
- randint
- random_integers
- random_sample
- random
- ranf
- sample
- choice
- bytes
-
-Permutations
-============
-.. autosummary::
- :toctree: generated/
-
- shuffle
- permutation
-
-Distributions
-=============
-.. autosummary::
- :toctree: generated/
-
- beta
- binomial
- chisquare
- dirichlet
- exponential
- f
- gamma
- geometric
- gumbel
- hypergeometric
- laplace
- logistic
- lognormal
- logseries
- multinomial
- multivariate_normal
- negative_binomial
- noncentral_chisquare
- noncentral_f
- normal
- pareto
- poisson
- power
- rayleigh
- standard_cauchy
- standard_exponential
- standard_gamma
- standard_normal
- standard_t
- triangular
- uniform
- vonmises
- wald
- weibull
- zipf
-
-Random generator
-================
-.. autosummary::
- :toctree: generated/
-
- RandomState
- seed
- get_state
- set_state
diff --git a/doc/source/reference/routines.rst b/doc/source/reference/routines.rst
index e3fbc2be6..7a9b97d77 100644
--- a/doc/source/reference/routines.rst
+++ b/doc/source/reference/routines.rst
@@ -41,7 +41,6 @@ indentation.
routines.other
routines.padding
routines.polynomials
- routines.random
random/index
routines.set
routines.sort