8000 ENH: np.random.default_gen() by rkern · Pull Request #13840 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: np.random.default_gen() #13840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 28, 2019
Prev Previous commit
Next Next commit
DOC: Remove some Generator() calls in the documentation.
  • Loading branch information
rkern committed Jun 26, 2019
commit f8801a10f41712b1939896d64d9063d35541a25c
7 changes: 4 additions & 3 deletions doc/source/reference/random/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ the random values are generated by `~PCG64`. The

.. code-block:: python

# As replacement for RandomState()
from numpy.random import Generator
rg = Generator()
# As replacement for RandomState(); default_gen() instantiates Generator with
# the default PCG64 BitGenerator.
from numpy.random import default_gen
rg = default_gen()
rg.standard_normal()
rg.bit_generator

Expand Down
12 changes: 6 additions & 6 deletions doc/source/reference/random/new-or-different.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Feature Older Equivalent Notes
source, called a `BitGenerator
<bit_generators>` A number of these
are provided. ``RandomState`` uses
only the Box- Muller method.
only the Mersenne Twister.
------------------ -------------------- -------------
``np.random.`` ``np.random.`` Access the values in a BitGenerator,
``Generator().`` ``random_sample()`` convert them to ``float64`` in the
``random()`` interval ``[0.0.,`` `` 1.0)``.
``Generator.`` ``RandomState.`` Access the values in a BitGenerator,
``random()`` ``random_sample()`` convert them to ``float64`` in the
interval ``[0.0.,`` `` 1.0)``.
In addition to the ``size`` kwarg, now
supports ``dtype='d'`` or ``dtype='f'``,
and an ``out`` kwarg to fill a user-
Expand All @@ -36,7 +36,7 @@ Feature Older Equivalent Notes
Many other distributions are also
supported.
------------------ -------------------- -------------
``Generator().`` ``randint``, Use the ``endpoint`` kwarg to adjust
``Generator.`` ``randint``, Use the ``endpoint`` kwarg to adjust
``integers()`` ``random_integers`` the inclusion or exclution of the
``high`` interval endpoint
================== ==================== =============
Expand All @@ -56,7 +56,7 @@ And in more detail:
random numbers from a discrete uniform distribution. The ``rand`` and
``randn`` methods are only available through the legacy `~.RandomState`.
This replaces both ``randint`` and the deprecated ``random_integers``.
* The Box-Muller used to produce NumPy's normals is no longer available.
* The Box-Muller method used to produce NumPy's normals is no longer available.
* All bit generators can produce doubles, uint64s and
uint32s via CTypes (`~PCG64.ctypes`) and CFFI (`~PCG64.cffi`).
This allows these bit generators to be used in numba.
Expand Down
0