summaryrefslogtreecommitdiff
path: root/doc/source/reference/random
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2019-05-13 14:17:51 -0700
committermattip <matti.picus@gmail.com>2019-05-20 19:00:34 +0300
commit17e0070df93f4262908f884dca4b08cb7d0bba7f (patch)
tree2db0eec024d5e021a36e6dca9f4b97d118bc9444 /doc/source/reference/random
parentdd77ce3cb84986308986974acfe988575323f75a (diff)
downloadnumpy-17e0070df93f4262908f884dca4b08cb7d0bba7f.tar.gz
MAINT: Implement API changes for randomgen-derived code
remove numpy.random.gen, BRNG.generator, pcg*, rand, randn remove use_mask and Lemire's method, fix benchmarks for PCG removal convert brng to bitgen (in C) and bit_generator (in python) convert base R{NG,andom.*} to BitGenerator, fix last commit randint -> integers, remove rand, randn, random_integers RandomGenerator -> Generator, more "basic RNG" -> BitGenerator random_sample -> random, jump -> jumped, resync with randomgen Remove derived code from entropy Port over changes accepted in upstream to protect log(0.0) where relevant fix doctests for jumped, better document choice Remove Python 2.7 shims Use NPY_INLINE to simplify Fix performance.py to work Renam directory brng to bit_generators Fix examples wiht new directory structure Clarify relationship to historical RandomState Remove references to .generator Rename xoshiro256/512starstar
Diffstat (limited to 'doc/source/reference/random')
-rw-r--r--doc/source/reference/random/bit_generators/dsfmt.rst (renamed from doc/source/reference/random/brng/dsfmt.rst)9
-rw-r--r--doc/source/reference/random/bit_generators/index.rst (renamed from doc/source/reference/random/brng/index.rst)19
-rw-r--r--doc/source/reference/random/bit_generators/mt19937.rst (renamed from doc/source/reference/random/brng/mt19937.rst)9
-rw-r--r--doc/source/reference/random/bit_generators/philox.rst (renamed from doc/source/reference/random/brng/philox.rst)9
-rw-r--r--doc/source/reference/random/bit_generators/threefry.rst (renamed from doc/source/reference/random/brng/threefry.rst)9
-rw-r--r--doc/source/reference/random/bit_generators/threefry32.rst (renamed from doc/source/reference/random/brng/threefry32.rst)9
-rw-r--r--doc/source/reference/random/bit_generators/xoroshiro128.rst (renamed from doc/source/reference/random/brng/xoroshiro128.rst)9
-rw-r--r--doc/source/reference/random/bit_generators/xorshift1024.rst (renamed from doc/source/reference/random/brng/xorshift1024.rst)9
-rw-r--r--doc/source/reference/random/bit_generators/xoshiro256.rst35
-rw-r--r--doc/source/reference/random/bit_generators/xoshiro512.rst35
-rw-r--r--doc/source/reference/random/brng/pcg32.rst43
-rw-r--r--doc/source/reference/random/brng/pcg64.rst43
-rw-r--r--doc/source/reference/random/brng/xoshiro256starstar.rst42
-rw-r--r--doc/source/reference/random/brng/xoshiro512starstar.rst42
-rw-r--r--doc/source/reference/random/change-log.rst39
-rw-r--r--doc/source/reference/random/extending.rst55
-rw-r--r--doc/source/reference/random/generator.rst103
-rw-r--r--doc/source/reference/random/index.rst73
-rw-r--r--doc/source/reference/random/legacy.rst21
-rw-r--r--doc/source/reference/random/multithreading.rst19
-rw-r--r--doc/source/reference/random/new-or-different.rst65
-rw-r--r--doc/source/reference/random/parallel.rst52
-rw-r--r--doc/source/reference/random/performance.py20
-rw-r--r--doc/source/reference/random/performance.rst66
-rw-r--r--doc/source/reference/random/references.rst5
25 files changed, 308 insertions, 532 deletions
diff --git a/doc/source/reference/random/brng/dsfmt.rst b/doc/source/reference/random/bit_generators/dsfmt.rst
index a47586a50..e7c6dbb31 100644
--- a/doc/source/reference/random/brng/dsfmt.rst
+++ b/doc/source/reference/random/bit_generators/dsfmt.rst
@@ -23,14 +23,7 @@ Parallel generation
.. autosummary::
:toctree: generated/
- ~DSFMT.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~DSFMT.generator
+ ~DSFMT.jumped
Extending
=========
diff --git a/doc/source/reference/random/brng/index.rst b/doc/source/reference/random/bit_generators/index.rst
index a7e5ad873..e3ca073c9 100644
--- a/doc/source/reference/random/brng/index.rst
+++ b/doc/source/reference/random/bit_generators/index.rst
@@ -1,12 +1,12 @@
-.. _brng:
+.. _bit_generator:
-Basic Random Number Generators
-------------------------------
+Bit Generators
+--------------
.. currentmodule:: numpy.random
-The random values produced by :class:`~RandomGenerator`
-are produced by a basic RNG. These basic RNGs do not directly provide
+The random values produced by :class:`~Generator`
+orignate in a BitGenerator. The BitGenerators do not directly provide
random numbers and only contains methods used for seeding, getting or
setting the state, jumping or advancing the state, and for accessing
low-level wrappers for consumption by code that can efficiently
@@ -20,23 +20,20 @@ Stable RNGs
DSFMT <dsfmt>
MT19937 <mt19937>
- PCG64 <pcg64>
Philox <philox>
ThreeFry <threefry>
XoroShiro128+ <xoroshiro128>
Xorshift1024*φ <xorshift1024>
- Xoshiro256** <xoshiro256starstar>
- Xoshiro512** <xoshiro512starstar>
+ Xoshiro256** <xoshiro256>
+ Xoshiro512** <xoshiro512>
Experimental RNGs
=================
-These RNGs are currently included for testing but are may not be
-permanent.
+These BitGenerators are currently included but are may not be permanent.
.. toctree::
:maxdepth: 1
- PCG32 <pcg32>
ThreeFry32 <threefry32>
diff --git a/doc/source/reference/random/brng/mt19937.rst b/doc/source/reference/random/bit_generators/mt19937.rst
index 1bd3597c8..f5843ccf0 100644
--- a/doc/source/reference/random/brng/mt19937.rst
+++ b/doc/source/reference/random/bit_generators/mt19937.rst
@@ -22,14 +22,7 @@ Parallel generation
.. autosummary::
:toctree: generated/
- ~MT19937.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~MT19937.generator
+ ~MT19937.jumped
Extending
=========
diff --git a/doc/source/reference/random/brng/philox.rst b/doc/source/reference/random/bit_generators/philox.rst
index c1e047c54..7ef451d4b 100644
--- a/doc/source/reference/random/brng/philox.rst
+++ b/doc/source/reference/random/bit_generators/philox.rst
@@ -23,14 +23,7 @@ Parallel generation
:toctree: generated/
~Philox.advance
- ~Philox.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~Philox.generator
+ ~Philox.jumped
Extending
=========
diff --git a/doc/source/reference/random/brng/threefry.rst b/doc/source/reference/random/bit_generators/threefry.rst
index eefe16ea0..951108d72 100644
--- a/doc/source/reference/random/brng/threefry.rst
+++ b/doc/source/reference/random/bit_generators/threefry.rst
@@ -23,14 +23,7 @@ Parallel generation
:toctree: generated/
~ThreeFry.advance
- ~ThreeFry.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~ThreeFry.generator
+ ~ThreeFry.jumped
Extending
=========
diff --git a/doc/source/reference/random/brng/threefry32.rst b/doc/source/reference/random/bit_generators/threefry32.rst
index f0d3dc281..1af9491a6 100644
--- a/doc/source/reference/random/brng/threefry32.rst
+++ b/doc/source/reference/random/bit_generators/threefry32.rst
@@ -23,14 +23,7 @@ Parallel generation
:toctree: generated/
~ThreeFry32.advance
- ~ThreeFry32.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~ThreeFry32.generator
+ ~ThreeFry32.jumped
Extending
=========
diff --git a/doc/source/reference/random/brng/xoroshiro128.rst b/doc/source/reference/random/bit_generators/xoroshiro128.rst
index 590552236..41f5238fc 100644
--- a/doc/source/reference/random/brng/xoroshiro128.rst
+++ b/doc/source/reference/random/bit_generators/xoroshiro128.rst
@@ -22,14 +22,7 @@ Parallel generation
.. autosummary::
:toctree: generated/
- ~Xoroshiro128.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~Xoroshiro128.generator
+ ~Xoroshiro128.jumped
Extending
=========
diff --git a/doc/source/reference/random/brng/xorshift1024.rst b/doc/source/reference/random/bit_generators/xorshift1024.rst
index 24ed3df04..5d0c9048f 100644
--- a/doc/source/reference/random/brng/xorshift1024.rst
+++ b/doc/source/reference/random/bit_generators/xorshift1024.rst
@@ -22,14 +22,7 @@ Parallel generation
.. autosummary::
:toctree: generated/
- ~Xorshift1024.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~Xorshift1024.generator
+ ~Xorshift1024.jumped
Extending
=========
diff --git a/doc/source/reference/random/bit_generators/xoshiro256.rst b/doc/source/reference/random/bit_generators/xoshiro256.rst
new file mode 100644
index 000000000..fedc61b33
--- /dev/null
+++ b/doc/source/reference/random/bit_generators/xoshiro256.rst
@@ -0,0 +1,35 @@
+Xoshiro256**
+------------
+
+.. module:: numpy.random.xoshiro256
+
+.. currentmodule:: numpy.random.xoshiro256
+
+.. autoclass:: Xoshiro256
+ :exclude-members:
+
+Seeding and State
+=================
+
+.. autosummary::
+ :toctree: generated/
+
+ ~Xoshiro256.seed
+ ~Xoshiro256.state
+
+Parallel generation
+===================
+.. autosummary::
+ :toctree: generated/
+
+ ~Xoshiro256.jumped
+
+Extending
+=========
+.. autosummary::
+ :toctree: generated/
+
+ ~Xoshiro256.cffi
+ ~Xoshiro256.ctypes
+
+
diff --git a/doc/source/reference/random/bit_generators/xoshiro512.rst b/doc/source/reference/random/bit_generators/xoshiro512.rst
new file mode 100644
index 000000000..e39346cd6
--- /dev/null
+++ b/doc/source/reference/random/bit_generators/xoshiro512.rst
@@ -0,0 +1,35 @@
+Xoshiro512**
+------------
+
+.. module:: numpy.random.xoshiro512
+
+.. currentmodule:: numpy.random.xoshiro512
+
+.. autoclass:: Xoshiro512
+ :exclude-members:
+
+Seeding and State
+=================
+
+.. autosummary::
+ :toctree: generated/
+
+ ~Xoshiro512.seed
+ ~Xoshiro512.state
+
+Parallel generation
+===================
+.. autosummary::
+ :toctree: generated/
+
+ ~Xoshiro512.jumped
+
+Extending
+=========
+.. autosummary::
+ :toctree: generated/
+
+ ~Xoshiro512.cffi
+ ~Xoshiro512.ctypes
+
+
diff --git a/doc/source/reference/random/brng/pcg32.rst b/doc/source/reference/random/brng/pcg32.rst
deleted file mode 100644
index f079f5a8c..000000000
--- a/doc/source/reference/random/brng/pcg32.rst
+++ /dev/null
@@ -1,43 +0,0 @@
-Parallel Congruent Generator (32-bit, PCG32)
---------------------------------------------
-
-.. module:: numpy.random.pcg32
-
-.. currentmodule:: numpy.random.pcg32
-
-.. autoclass:: PCG32
- :exclude-members:
-
-Seeding and State
-=================
-
-.. autosummary::
- :toctree: generated/
-
- ~PCG32.seed
- ~PCG32.state
-
-Parallel generation
-===================
-.. autosummary::
- :toctree: generated/
-
- ~PCG32.advance
- ~PCG32.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~PCG32.generator
-
-Extending
-=========
-.. autosummary::
- :toctree: generated/
-
- ~PCG32.cffi
- ~PCG32.ctypes
-
-
diff --git a/doc/source/reference/random/brng/pcg64.rst b/doc/source/reference/random/brng/pcg64.rst
deleted file mode 100644
index 93f026fcb..000000000
--- a/doc/source/reference/random/brng/pcg64.rst
+++ /dev/null
@@ -1,43 +0,0 @@
-Parallel Congruent Generator (64-bit, PCG64)
---------------------------------------------
-
-.. module:: numpy.random.pcg64
-
-.. currentmodule:: numpy.random.pcg64
-
-.. autoclass:: PCG64
- :exclude-members:
-
-Seeding and State
-=================
-
-.. autosummary::
- :toctree: generated/
-
- ~PCG64.seed
- ~PCG64.state
-
-Parallel generation
-===================
-.. autosummary::
- :toctree: generated/
-
- ~PCG64.advance
- ~PCG64.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~PCG64.generator
-
-Extending
-=========
-.. autosummary::
- :toctree: generated/
-
- ~PCG64.cffi
- ~PCG64.ctypes
-
-
diff --git a/doc/source/reference/random/brng/xoshiro256starstar.rst b/doc/source/reference/random/brng/xoshiro256starstar.rst
deleted file mode 100644
index 85c445666..000000000
--- a/doc/source/reference/random/brng/xoshiro256starstar.rst
+++ /dev/null
@@ -1,42 +0,0 @@
-Xoshiro256**
-------------
-
-.. module:: numpy.random.xoshiro256starstar
-
-.. currentmodule:: numpy.random.xoshiro256starstar
-
-.. autoclass:: Xoshiro256StarStar
- :exclude-members:
-
-Seeding and State
-=================
-
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro256StarStar.seed
- ~Xoshiro256StarStar.state
-
-Parallel generation
-===================
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro256StarStar.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro256StarStar.generator
-
-Extending
-=========
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro256StarStar.cffi
- ~Xoshiro256StarStar.ctypes
-
-
diff --git a/doc/source/reference/random/brng/xoshiro512starstar.rst b/doc/source/reference/random/brng/xoshiro512starstar.rst
deleted file mode 100644
index 0c008d56e..000000000
--- a/doc/source/reference/random/brng/xoshiro512starstar.rst
+++ /dev/null
@@ -1,42 +0,0 @@
-Xoshiro512**
-------------
-
-.. module:: numpy.random.xoshiro512starstar
-
-.. currentmodule:: numpy.random.xoshiro512starstar
-
-.. autoclass:: Xoshiro512StarStar
- :exclude-members:
-
-Seeding and State
-=================
-
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro512StarStar.seed
- ~Xoshiro512StarStar.state
-
-Parallel generation
-===================
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro512StarStar.jump
-
-Random Generator
-================
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro512StarStar.generator
-
-Extending
-=========
-.. autosummary::
- :toctree: generated/
-
- ~Xoshiro512StarStar.cffi
- ~Xoshiro512StarStar.ctypes
-
-
diff --git a/doc/source/reference/random/change-log.rst b/doc/source/reference/random/change-log.rst
deleted file mode 100644
index 1d9f2fefc..000000000
--- a/doc/source/reference/random/change-log.rst
+++ /dev/null
@@ -1,39 +0,0 @@
-Change Log for the original bashtage/randomgen repo
----------------------------------------------------
-v1.16.1
-=======
-- Synchronized with upstream changes.
-- Fixed a bug in gamma generation if the shape parameters is 0.0.
-
-v1.16.0
-=======
-- Fixed a bug that affected ``randomgen.dsfmt.DSFMT`` when calling
- ``~randomgen.dsfmt.DSFMT.jump`` or ``randomgen.dsfmt.DSFMT.seed``
- that failed to reset the buffer. This resulted in upto 381 values from the
- previous state being used before the buffer was refilled at the new state.
-- Fixed bugs in ``randomgen.xoshiro512starstar.Xoshiro512StarStar``
- and ``randomgen.xorshift1024.Xorshift1024`` where the fallback
- entropy initialization used too few bytes. This bug is unlikely to be
- encountered since this path is only encountered if the system random
- number generator fails.
-- Synchronized with upstream changes.
-
-v1.15.1
-=======
-- Added Xoshiro256** and Xoshiro512**, the preferred generators of this class.
-- Fixed bug in `jump` method of Random123 generators which did nto specify a default value.
-- Added support for generating bounded uniform integers using Lemire's method.
-- Synchronized with upstream changes, which requires moving the minimum supported NumPy to 1.13.
-
-v1.15
-=====
-- Synced empty choice changes
-- Synced upstream docstring changes
-- Synced upstream changes in permutation
-- Synced upstream doc fixes
-- Added absolute_import to avoid import noise on Python 2.7
-- Add legacy generator mtrand which allows NumPy replication
-- Improve type handling of integers
-- Switch to array-fillers for 0 parameter distribution to improve performance
-- Small changes to build on manylinux
-- Build wheels using multibuild
diff --git a/doc/source/reference/random/extending.rst b/doc/source/reference/random/extending.rst
index f76e3984f..f65d7708f 100644
--- a/doc/source/reference/random/extending.rst
+++ b/doc/source/reference/random/extending.rst
@@ -2,16 +2,15 @@
Extending
---------
-The basic RNGs have been designed to be extendable using standard tools for
-high-performance Python -- numba and Cython.
-The `~RandomGenerator` object can also be used with
-user-provided basic RNGs as long as these export a small set of required
-functions.
+The BitGenerators have been designed to be extendable using standard tools for
+high-performance Python -- numba and Cython. The `~Generator` object can also
+be used with user-provided BitGenerators as long as these export a small set of
+required functions.
Numba
=====
Numba can be used with either CTypes or CFFI. The current iteration of the
-basic RNGs all export a small set of functions through both interfaces.
+BitGenerators all export a small set of functions through both interfaces.
This example shows how numba can be used to produce Box-Muller normals using
a pure Python implementation which is then compiled. The random numbers are
@@ -66,7 +65,7 @@ examples folder.
Cython
======
-Cython can be used to unpack the ``PyCapsule`` provided by a basic RNG.
+Cython can be used to unpack the ``PyCapsule`` provided by a BitGenerator.
This example uses `~xoroshiro128.Xoroshiro128` and
``random_gauss_zig``, the Ziggurat-based generator for normals, to fill an
array. The usual caveats for writing high-performance code using Cython --
@@ -81,33 +80,29 @@ removing bounds checks and wrap around, providing array alignment information
from cpython.pycapsule cimport PyCapsule_IsValid, PyCapsule_GetPointer
from numpy.random.common cimport *
from numpy.random.distributions cimport random_gauss_zig
- from numpy.random.xoroshiro128 import Xoroshiro128
+ from numpy.random import Xoroshiro128
@cython.boundscheck(False)
@cython.wraparound(False)
def normals_zig(Py_ssize_t n):
cdef Py_ssize_t i
- cdef brng_t *rng
- cdef const char *capsule_name = "BasicRNG"
+ cdef bitgen_t *rng
+ cdef const char *capsule_name = "BitGenerator"
cdef double[::1] random_values
x = Xoroshiro128()
capsule = x.capsule
- # Optional check that the capsule if from a Basic RNG
if not PyCapsule_IsValid(capsule, capsule_name):
raise ValueError("Invalid pointer to anon_func_state")
- # Cast the pointer
- rng = <brng_t *> PyCapsule_GetPointer(capsule, capsule_name)
+ rng = <bitgen_t *> PyCapsule_GetPointer(capsule, capsule_name)
random_values = np.empty(n)
for i in range(n):
- # Call the function
random_values[i] = random_gauss_zig(rng)
randoms = np.asarray(random_values)
return randoms
-
-The basic RNG can also be directly accessed using the members of the basic
+The BitGenerator can also be directly accessed using the members of the basic
RNG structure.
.. code-block:: cython
@@ -116,8 +111,8 @@ RNG structure.
@cython.wraparound(False)
def uniforms(Py_ssize_t n):
cdef Py_ssize_t i
- cdef brng_t *rng
- cdef const char *capsule_name = "BasicRNG"
+ cdef bitgen_t *rng
+ cdef const char *capsule_name = "BitGenerator"
cdef double[::1] random_values
x = Xoroshiro128()
@@ -126,7 +121,7 @@ RNG structure.
if not PyCapsule_IsValid(capsule, capsule_name):
raise ValueError("Invalid pointer to anon_func_state")
# Cast the pointer
- rng = <brng_t *> PyCapsule_GetPointer(capsule, capsule_name)
+ rng = <bitgen_t *> PyCapsule_GetPointer(capsule, capsule_name)
random_values = np.empty(n)
for i in range(n):
# Call the function
@@ -139,29 +134,29 @@ examples folder.
New Basic RNGs
==============
-`~RandomGenerator` can be used with other
-user-provided basic RNGs. The simplest way to write a new basic RNG is to
-examine the pyx file of one of the existing basic RNGs. The key structure
-that must be provided is the ``capsule`` which contains a ``PyCapsule`` to a
-struct pointer of type ``brng_t``,
+`~Generator` can be used with other user-provided BitGenerators. The simplest
+way to write a new BitGenerator is to examine the pyx file of one of the
+existing BitGenerators. The key structure that must be provided is the
+``capsule`` which contains a ``PyCapsule`` to a struct pointer of type
+``bitgen_t``,
.. code-block:: c
- typedef struct brng {
+ typedef struct bitgen {
void *state;
uint64_t (*next_uint64)(void *st);
uint32_t (*next_uint32)(void *st);
double (*next_double)(void *st);
uint64_t (*next_raw)(void *st);
- } brng_t;
+ } bitgen_t;
which provides 5 pointers. The first is an opaque pointer to the data structure
-used by the basic RNG. The next three are function pointers which return the
-next 64- and 32-bit unsigned integers, the next random double and the next
+used by the BitGenerators. The next three are function pointers which return
+the next 64- and 32-bit unsigned integers, the next random double and the next
raw value. This final function is used for testing and so can be set to
the next 64-bit unsigned integer function if not needed. Functions inside
-``RandomGenerator`` use this structure as in
+``Generator`` use this structure as in
.. code-block:: c
- brng_state->next_uint64(brng_state->state)
+ bitgen_state->next_uint64(bitgen_state->state)
diff --git a/doc/source/reference/random/generator.rst b/doc/source/reference/random/generator.rst
index 9d248732f..ee70725e7 100644
--- a/doc/source/reference/random/generator.rst
+++ b/doc/source/reference/random/generator.rst
@@ -2,84 +2,81 @@
Random Generator
----------------
-The `~RandomGenerator` provides access to
+The `~Generator` provides access to
a wide range of distributions, and served as a replacement for
:class:`~numpy.random.RandomState`. The main difference between
-the two is that ``RandomGenerator`` relies on an additional basic RNG to
+the two is that ``Generator`` relies on an additional BitGenerator to
manage state and generate the random bits, which are then transformed into
-random values from useful distributions. The default basic RNG used by
-``RandomGenerator`` is :class:`~xoroshiro128.Xoroshiro128`. The basic RNG can be
-changed by passing an instantized basic RNG to ``RandomGenerator``.
+random values from useful distributions. The default BitGenerator used by
+``Generator`` is :class:`~xoroshiro128.Xoroshiro128`. The BitGenerator
+can be changed by passing an instantized BitGenerator to ``Generator``.
-.. autoclass:: RandomGenerator
+.. autoclass:: Generator
:exclude-members:
-Accessing the RNG
-=================
+Accessing the BitGenerator
+==========================
.. autosummary::
:toctree: generated/
- ~RandomGenerator.brng
+ ~Generator.bit_generator
Simple random data
==================
.. autosummary::
:toctree: generated/
- ~RandomGenerator.rand
- ~RandomGenerator.randn
- ~RandomGenerator.randint
- ~RandomGenerator.random_integers
- ~RandomGenerator.random_sample
- ~RandomGenerator.choice
- ~RandomGenerator.bytes
+ ~Generator.integers
+ ~Generator.random
+ ~Generator.choice
+ ~Generator.bytes
Permutations
============
.. autosummary::
:toctree: generated/
- ~RandomGenerator.shuffle
- ~RandomGenerator.permutation
+ ~Generator.shuffle
+ ~Generator.permutation
Distributions
=============
.. autosummary::
:toctree: generated/
- ~RandomGenerator.beta
- ~RandomGenerator.binomial
- ~RandomGenerator.chisquare
- ~RandomGenerator.dirichlet
- ~RandomGenerator.exponential
- ~RandomGenerator.f
- ~RandomGenerator.gamma
- ~RandomGenerator.geometric
- ~RandomGenerator.gumbel
- ~RandomGenerator.hypergeometric
- ~RandomGenerator.laplace
- ~RandomGenerator.logistic
- ~RandomGenerator.lognormal
- ~RandomGenerator.logseries
- ~RandomGenerator.multinomial
- ~RandomGenerator.multivariate_normal
- ~RandomGenerator.negative_binomial
- ~RandomGenerator.noncentral_chisquare
- ~RandomGenerator.noncentral_f
- ~RandomGenerator.normal
- ~RandomGenerator.pareto
- ~RandomGenerator.poisson
- ~RandomGenerator.power
- ~RandomGenerator.rayleigh
- ~RandomGenerator.standard_cauchy
- ~RandomGenerator.standard_exponential
- ~RandomGenerator.standard_gamma
- ~RandomGenerator.standard_normal
- ~RandomGenerator.standard_t
- ~RandomGenerator.triangular
- ~RandomGenerator.uniform
- ~RandomGenerator.vonmises
- ~RandomGenerator.wald
- ~RandomGenerator.weibull
- ~RandomGenerator.zipf
+ ~Generator.beta
+ ~Generator.binomial
+ ~Generator.chisquare
+ ~Generator.dirichlet
+ ~Generator.exponential
+ ~Generator.f
+ ~Generator.gamma
+ ~Generator.geometric
+ ~Generator.gumbel
+ ~Generator.hypergeometric
+ ~Generator.laplace
+ ~Generator.logistic
+ ~Generator.lognormal
+ ~Generator.logseries
+ ~Generator.multinomial
+ ~Generator.multivariate_normal
+ ~Generator.negative_binomial
+ ~Generator.noncentral_chisquare
+ ~Generator.noncentral_f
+ ~Generator.normal
+ ~Generator.pareto
+ ~Generator.poisson
+ ~Generator.power
+ ~Generator.rayleigh
+ ~Generator.standard_cauchy
+ ~Generator.standard_exponential
+ ~Generator.standard_gamma
+ ~Generator.standard_normal
+ ~Generator.standard_t
+ ~Generator.triangular
+ ~Generator.uniform
+ ~Generator.vonmises
+ ~Generator.wald
+ ~Generator.weibull
+ ~Generator.zipf
diff --git a/doc/source/reference/random/index.rst b/doc/source/reference/random/index.rst
index 9c8c99c38..032db8562 100644
--- a/doc/source/reference/random/index.rst
+++ b/doc/source/reference/random/index.rst
@@ -39,28 +39,28 @@ which will be faster than the legacy methods in `RandomState`
from numpy import random
random.standard_normal()
-`Generator` can be used as a direct replacement for `RandomState`,
-although the random values are generated by `~xoroshiro128.Xoroshiro128`. The
+`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``.
.. code-block:: python
# As replacement for RandomState()
- from numpy.random import RandomGenerator
- rg = RandomGenerator()
+ from numpy.random import Generator
+ rg = Generator()
rg.standard_normal()
rg.bit_generator
-Seeds can be passed to any of the basic RNGs. Here `mt19937.MT19937` is used
-and the ``RandomGenerator`` is accessed via the attribute `mt19937.MT19937.
-generator`.
+Seeds can be passed to any of the BitGenerators. Here `mt19937.MT19937` is used
+and is the wrapped with a `~.Generator`.
+
.. code-block:: python
- from numpy.random import MT19937
- rg = MT19937(12345).generator
+ from numpy.random import Generator, MT19937
+ rg = Generator(MT19937(12345))
rg.standard_normal()
@@ -70,33 +70,32 @@ RandomGen takes a different approach to producing random numbers from the
`RandomState` object. Random number generation is separated into two
components, a bit generator and a random generator.
-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.
+The bit generator has a limited set of responsibilities. It manages state
+and provides functions to produce random doubles and random unsigned 32- and
+64-bit values. The bit generator also handles all seeding which varies with
+different bit generators.
The `random generator <Generator>` takes the
bit generator-provided stream and transforms them into more useful
distributions, e.g., simulated normal random values. This structure allows
-alternative basic RNGs to be used without code duplication.
+alternative bit generators to be used with little code duplication.
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.
-
+the sole argument. Note that the BitGenerator must be instantiated.
.. code-block:: python
- rg = RandomGenerator(MT19937(12345))
- rg.random_sample()
+ from numpy.random import Generator, MT19937
+ rg = Generator(MT19937())
+ rg.random()
-A shorthand method is also available which uses the `~mt19937.MT19937.
-generator` property from a basic RNG to access an embedded random generator.
+Seed information is directly passed to the bit generator.
.. code-block:: python
- rg = MT19937(12345).generator
- rg.random_sample()
+ rg = Generator(MT19937(12345))
+ rg.random()
What's New or Different
~~~~~~~~~~~~~~~~~~~~~~~
@@ -136,7 +135,7 @@ What's New or Different
is consistent with Python's `random.random`.
See :ref:`new-or-different` for a complete list of improvements and
-differences.
+differences from the traditional ``Randomstate``.
Parallel Generation
~~~~~~~~~~~~~~~~~~~
@@ -156,33 +155,32 @@ The included BitGenerators are:
that returns a new generator with state as-if ``2**128`` draws have been made.
* dSFMT - SSE2 enabled versions of the MT19937 generator. Theoretically
the same, but with a different state and so it is not possible to produce a
- sequence identical to MT19937. Supports ``jump`` and so can
+ sequence identical to MT19937. Supports ``jumped`` and so can
be used in parallel applications. See the `dSFMT authors' page`_.
* XoroShiro128+ - Improved version of XorShift128+ with better performance
and statistical quality. Like the XorShift generators, it can be jumped
to produce multiple streams in parallel applications. See
- `~xoroshiro128.Xoroshiro128.jump` for details.
- More information about this PRNG is available at the
+ `~xoroshiro128.Xoroshiro128.jumped` for details.
+ More information about this bit generator is available at the
`xorshift, xoroshiro and xoshiro authors' page`_.
* XorShift1024*φ - Fast fast generator based on the XSadd
- generator. Supports ``jump`` and so can be used in
+ generator. Supports ``jumped`` and so can be used in
parallel applications. See the documentation for
`~xorshift1024.Xorshift1024.jumped` for details. More
information about these bit generators is available at the
`xorshift, xoroshiro and xoshiro authors' page`_.
* Xorshiro256** and Xorshiro512** - The most recently introduced XOR,
- shift, and rotate generator. Supports ``jump`` and so can be used in
+ shift, and rotate generator. Supports ``jumped`` and so can be used in
parallel applications. See the documentation for
`~xoshiro256.Xoshirt256.jumped` for details. More information about these bit
generators is available at the `xorshift, xoroshiro and xoshiro authors'
page`_.
* ThreeFry and Philox - counter-based generators capable of being advanced an
arbitrary number of steps or generating independent streams. See the
- `Random123`_ page for more details about this class of PRNG.
+ `Random123`_ page for more details about this class of bit generators.
.. _`dSFMT authors' page`: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/
.. _`xorshift, xoroshiro and xoshiro authors' page`: http://xoroshiro.di.unimi.it/
-.. _`PCG author's page`: http://www.pcg-random.org/
.. _`Random123`: https://www.deshawresearch.com/resources_random123.html
Generator
@@ -201,8 +199,8 @@ BitGenerators
BitGenerators <bit_generators/index>
-New Features
-------------
+Features
+--------
.. toctree::
:maxdepth: 2
@@ -212,16 +210,9 @@ New Features
Comparing Performance <performance>
extending
Reading System Entropy <entropy>
- references
-Changes
-~~~~~~~
+Original Source
+~~~~~~~~~~~~~~~
This package was developed independently of NumPy and was integrated in version
1.17.0. The original repo is at https://github.com/bashtage/randomgen.
-
-.. toctree::
- :maxdepth: 2
-
- Change Log <change-log>
-
diff --git a/doc/source/reference/random/legacy.rst b/doc/source/reference/random/legacy.rst
index 3bf7569b0..c5b92f1bb 100644
--- a/doc/source/reference/random/legacy.rst
+++ b/doc/source/reference/random/legacy.rst
@@ -3,16 +3,18 @@
Legacy Random Generation
------------------------
The `~mtrand.RandomState` provides access to
-legacy generators. These all depend on Box-Muller normals or
-inverse CDF exponentials or gammas. This class should only be used
+legacy generators. This generator is considered frozen and will have
+no further improvements. It is guaranteed to produce the same values
+as the final point release of NumPy v1.16. These all depend on Box-Muller
+normals or inverse CDF exponentials or gammas. This class should only be used
if it is essential to have randoms that are identical to what
would have been produced by NumPy.
`~mtrand.RandomState` adds additional information
to the state which is required when using Box-Muller normals since these
are produced in pairs. It is important to use
-`~mtrand.RandomState.get_state`
-when accessing the state so that these extra values are saved.
+`~mtrand.RandomState.get_state`, and not the underlying bit generators
+`state`, when accessing the state so that these extra values are saved.
.. warning::
@@ -30,20 +32,19 @@ when accessing the state so that these extra values are saved.
.. code-block:: python
from numpy.random import MT19937
- from numpy.random._mtrand import RandomState as LegacyGenerator
from numpy.random import RandomState
- # Use same seed
+
+ # Use same seed
rs = RandomState(12345)
mt19937 = MT19937(12345)
- rg = RandomGenerator(mt19937)
- lg = LegacyGenerator(mt19937)
+ lg = RandomState(mt19937)
# Identical output
rs.standard_normal()
lg.standard_normal()
- rs.random_sample()
- rg.random_sample()
+ rs.random()
+ lg.random()
rs.standard_exponential()
lg.standard_exponential()
diff --git a/doc/source/reference/random/multithreading.rst b/doc/source/reference/random/multithreading.rst
index d35cafe06..718fe05f1 100644
--- a/doc/source/reference/random/multithreading.rst
+++ b/doc/source/reference/random/multithreading.rst
@@ -17,7 +17,7 @@ seed will produce the same outputs.
.. code-block:: ipython
- from numpy.random import Xorshift1024
+ from numpy.random import Generator, Xorshift1024
import multiprocessing
import concurrent.futures
import numpy as np
@@ -29,14 +29,13 @@ seed will produce the same outputs.
threads = multiprocessing.cpu_count()
self.threads = threads
- self._random_generators = []
+ self._random_generators = [rg]
+ last_rg = rg
for _ in range(0, threads-1):
- _rg = Xorshift1024()
- _rg.state = rg.state
- self._random_generators.append(_rg.generator)
- rg.jump()
- self._random_generators.append(rg.generator)
-
+ new_rg = last_rg.jumped()
+ self._random_generators.append(new_rg)
+ last_rg = new_rg
+
self.n = n
self.executor = concurrent.futures.ThreadPoolExecutor(threads)
self.values = np.empty(n)
@@ -90,7 +89,7 @@ The single threaded call directly uses the BitGenerator.
.. code-block:: ipython
In [5]: values = np.empty(10000000)
- ...: rg = Xorshift1024().generator
+ ...: rg = Generator(Xorshift1024())
...: %timeit rg.standard_normal(out=values)
99.6 ms ± 222 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
@@ -101,7 +100,7 @@ that does not use an existing array due to array creation overhead.
.. code-block:: ipython
- In [6]: rg = Xorshift1024().generator
+ In [6]: rg = Generator(Xorshift1024())
...: %timeit rg.standard_normal(10000000)
125 ms ± 309 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
diff --git a/doc/source/reference/random/new-or-different.rst b/doc/source/reference/random/new-or-different.rst
index 4922b6762..906cceceb 100644
--- a/doc/source/reference/random/new-or-different.rst
+++ b/doc/source/reference/random/new-or-different.rst
@@ -35,7 +35,11 @@ Feature Older Equivalent Notes
Many other distributions are also
supported.
-=================== =================== =============
+------------------ -------------------- -------------
+``Generator().`` ``randint``, Use the ``endpoint`` kwarg to adjust
+``integers()`` ``random_integers`` the inclusion or exclution of the
+ ``high`` interval endpoint
+================== ==================== =============
And in more detail:
@@ -43,26 +47,29 @@ And in more detail:
source of randomness that is used in cryptographic applications (e.g.,
``/dev/urandom`` on Unix).
* Simulate from the complex normal distribution
- (`~.RandomGenerator.complex_normal`)
+ (`~.Generator.complex_normal`)
* The normal, exponential and gamma generators use 256-step Ziggurat
methods which are 2-10 times faster than NumPy's default implementation in
- `~.RandomGenerator.standard_normal`,
- `~.RandomGenerator.standard_exponential` or
- `~.RandomGenerator.standard_gamma`.
+ `~.Generator.standard_normal`, `~.Generator.standard_exponential` or
+ `~.Generator.standard_gamma`.
+* `~.Generator.integers` is now the canonical way to generate integer
+ random numbers from a discrete uniform distribution. The ``rand`` and
+ ``randn`` methods are only availabe 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.
-* All basic random generators functions to produce doubles, uint64s and
+* All bit generators can produce doubles, uint64s and
uint32s via CTypes (`~.xoroshiro128.Xoroshiro128.
ctypes`) and CFFI (`~.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
+ This allows these bit generators to be used in numba.
+* The bit generators can be used in downstream projects via
Cython.
.. ipython:: python
- from numpy.random import Xoroshiro128
+ from numpy.random import Generator, Xoroshiro128
import numpy.random
- rg = Xoroshiro128().generator
+ rg = Generator(Xoroshiro128())
%timeit rg.standard_normal(100000)
%timeit numpy.random.standard_normal(100000)
@@ -80,27 +87,25 @@ And in more detail:
to produce either single or double prevision uniform random variables for
select distributions
- * Uniforms (`~.RandomGenerator.random_sample` and
- `~.RandomGenerator.rand`)
- * Normals (`~.RandomGenerator.standard_normal` and
- `~.RandomGenerator.randn`)
- * Standard Gammas (`~.RandomGenerator.standard_gamma`)
- * Standard Exponentials (`~.RandomGenerator.standard_exponential`)
+ * Uniforms (`~.Generator.random` and `~.Generator.integers`)
+ * Normals (`~.Generator.standard_normal`)
+ * Standard Gammas (`~.Generator.standard_gamma`)
+ * Standard Exponentials (`~.Generator.standard_exponential`)
.. ipython:: python
- rg.brng.seed(0)
- rg.random_sample(3, dtype='d')
- rg.brng.seed(0)
- rg.random_sample(3, dtype='f')
+ rg.bit_generator.seed(0)
+ rg.random(3, dtype='d')
+ rg.bit_generator.seed(0)
+ rg.random(3, dtype='f')
* Optional ``out`` argument that allows existing arrays to be filled for
select distributions
- * Uniforms (`~.RandomGenerator.random_sample`)
- * Normals (`~.RandomGenerator.standard_normal`)
- * Standard Gammas (`~.RandomGenerator.standard_gamma`)
- * Standard Exponentials (`~.RandomGenerator.standard_exponential`)
+ * Uniforms (`~.Generator.random`)
+ * Normals (`~.Generator.standard_normal`)
+ * Standard Gammas (`~.Generator.standard_gamma`)
+ * Standard Exponentials (`~.Generator.standard_exponential`)
This allows multithreading to fill large arrays in chunks using suitable
BitGenerators in parallel.
@@ -108,16 +113,6 @@ And in more detail:
.. ipython:: python
existing = np.zeros(4)
- rg.random_sample(out=existing[:2])
+ rg.random(out=existing[:2])
print(existing)
-.. * For changes since the previous release, see the :ref:`change-log`
-
-* Support for Lemire’s method of generating uniform integers on an
- arbitrary interval by setting ``use_masked=True`` in
- (`~.RandomGenerator.randint`).
-
-.. ipython:: python
-
- %timeit rg.randint(0, 1535, use_masked=False)
- %timeit numpy.random.randint(0, 1535)
diff --git a/doc/source/reference/random/parallel.rst b/doc/source/reference/random/parallel.rst
index c831effa2..8bdc3f23f 100644
--- a/doc/source/reference/random/parallel.rst
+++ b/doc/source/reference/random/parallel.rst
@@ -12,20 +12,20 @@ or distributed).
Independent Streams
-------------------
-:class:`~pcg64.PCG64`, :class:`~threefry.ThreeFry`
-and :class:`~philox.Philox` support independent streams. This
-example shows how many streams can be created by passing in different index
-values in the second input while using the same seed in the first.
+:class:`~threefry.ThreeFry` and :class:`~philox.Philox` support independent
+streams. This example shows how many streams can be created by passing in
+different index values in the second input while using the same seed in the
+first.
.. code-block:: python
from numpy.random.entropy import random_entropy
- from numpy.random import PCG64
+ from numpy.random import ThreeFry
entropy = random_entropy(4)
# 128-bit number as a seed
seed = sum([int(entropy[i]) * 2 ** (32 * i) for i in range(4)])
- streams = [PCG64(seed, stream) for stream in range(10)]
+ streams = [ThreeFry(seed, stream) for stream in range(10)]
:class:`~philox.Philox` and :class:`~threefry.ThreeFry` are
@@ -49,8 +49,8 @@ to produce independent streams.
Jump/Advance the BitGenerator state
-----------------------------------
-Jump
-****
+Jumped
+******
``jumped`` advances the state of the BitGenerator *as-if* a large number of
random numbers have been drawn, and returns a new instance with this state.
@@ -68,8 +68,6 @@ are listed below.
+-----------------+-------------------------+-------------------------+-------------------------+
| MT19937 | :math:`2^{19937}` | :math:`2^{128}` | 32 |
+-----------------+-------------------------+-------------------------+-------------------------+
-| PCG64 | :math:`2^{128}` | :math:`2^{64}` | 64 |
-+-----------------+-------------------------+-------------------------+-------------------------+
| Philox | :math:`2^{256}` | :math:`2^{128}` | 64 |
+-----------------+-------------------------+-------------------------+-------------------------+
| ThreeFry | :math:`2^{256}` | :math:`2^{128}` | 64 |
@@ -78,6 +76,10 @@ are listed below.
+-----------------+-------------------------+-------------------------+-------------------------+
| Xorshift1024 | :math:`2^{1024}` | :math:`2^{512}` | 64 |
+-----------------+-------------------------+-------------------------+-------------------------+
+| Xoshiro256** | :math:`2^{256}` | :math:`2^{128}` | 64 |
++-----------------+-------------------------+-------------------------+-------------------------+
+| Xoshiro512** | :math:`2^{512}` | :math:`2^{256}` | 64 |
++-----------------+-------------------------+-------------------------+-------------------------+
``jumped`` can be used to produce long blocks which should be long enough to not
overlap.
@@ -93,16 +95,14 @@ overlap.
blocked_rng = []
rng = Xorshift1024(seed)
for i in range(10):
- blocked_rng.append(rng.jumped())
-
+ blocked_rng.append(rng.jumped(i))
Advance
*******
``advance`` can be used to jump the state an arbitrary number of steps, and so
-is a more general approach than ``jump``. :class:`~pcg64.PCG64`,
-:class:`~threefry.ThreeFry` and :class:`~philox.Philox`
-support ``advance``, and since these also support independent
-streams, it is not usually necessary to use ``advance``.
+is a more general approach than ``jumped``. :class:`~threefry.ThreeFry` and
+:class:`~philox.Philox` support ``advance``, and since these also support
+independent streams, it is not usually necessary to use ``advance``.
Advancing a BitGenerator updates the underlying state as-if a given number of
calls to the BitGenerator have been made. In general there is not a
@@ -120,23 +120,23 @@ This occurs for two reasons:
Advancing the BitGenerator state resets any pre-computed random numbers. This
is required to ensure exact reproducibility.
-This example uses ``advance`` to advance a :class:`~pcg64.PCG64`
+This example uses ``advance`` to advance a :class:`~threefry.ThreeFry`
generator 2 ** 127 steps to set a sequence of random number generators.
.. code-block:: python
- from numpy.random import PCG64
- brng = PCG64()
- brng_copy = PCG64()
- brng_copy.state = brng.state
+ from numpy.random import ThreeFry
+ bit_generator = ThreeFry()
+ bit_generator_copy = ThreeFry()
+ bit_generator_copy.state = bit_generator.state
advance = 2**127
- brngs = [brng]
+ bit_generators = [bit_generator]
for _ in range(9):
- brng_copy.advance(advance)
- brng = PCG64()
- brng.state = brng_copy.state
- brngs.append(brng)
+ bit_generator_copy.advance(advance)
+ bit_generator = ThreeFry()
+ bit_generator.state = bit_generator_copy.state
+ bit_generators.append(bit_generator)
.. end block
diff --git a/doc/source/reference/random/performance.py b/doc/source/reference/random/performance.py
index 12cbbc5d3..a29e09c41 100644
--- a/doc/source/reference/random/performance.py
+++ b/doc/source/reference/random/performance.py
@@ -4,16 +4,15 @@ from timeit import repeat
import numpy as np
import pandas as pd
-from randomgen import MT19937, DSFMT, ThreeFry, PCG64, Xoroshiro128, \
- Xorshift1024, Philox, Xoshiro256StarStar, Xoshiro512StarStar
+from numpy.random import MT19937, DSFMT, ThreeFry, Xoroshiro128, \
+ Xorshift1024, Philox, Xoshiro256, Xoshiro512
-PRNGS = [DSFMT, MT19937, Philox, PCG64, ThreeFry, Xoroshiro128, Xorshift1024,
- Xoshiro256StarStar, Xoshiro512StarStar]
+PRNGS = [DSFMT, MT19937, Philox, ThreeFry, Xoroshiro128, Xorshift1024,
+ Xoshiro256, Xoshiro512]
-funcs = {'32-bit Unsigned Ints': 'random_uintegers(size=1000000,bits=32)',
- '64-bit Unsigned Ints': 'random_uintegers(size=1000000,bits=32)',
- 'Uniforms': 'random_sample(size=1000000)',
- 'Complex Normals': 'complex_normal(size=1000000)',
+funcs = {'32-bit Unsigned Ints': 'integers(0, 2**32,size=1000000, dtype="uint32")',
+ '64-bit Unsigned Ints': 'integers(0, 2**64,size=1000000, dtype="uint64")',
+ 'Uniforms': 'random(size=1000000)',
'Normals': 'standard_normal(size=1000000)',
'Exponentials': 'standard_exponential(size=1000000)',
'Gammas': 'standard_gamma(3.0,size=1000000)',
@@ -22,8 +21,8 @@ funcs = {'32-bit Unsigned Ints': 'random_uintegers(size=1000000,bits=32)',
'Poissons': 'poisson(3.0, size=1000000)', }
setup = """
-from randomgen import {prng}
-rg = {prng}().generator
+from numpy.random import {prng}, Generator
+rg = Generator({prng}())
"""
test = "rg.{func}"
@@ -43,7 +42,6 @@ npfuncs = OrderedDict()
npfuncs.update(funcs)
npfuncs['32-bit Unsigned Ints'] = 'randint(2**32,dtype="uint32",size=1000000)'
npfuncs['64-bit Unsigned Ints'] = 'tomaxint(size=1000000)'
-del npfuncs['Complex Normals']
setup = """
from numpy.random import RandomState
rg = RandomState()
diff --git a/doc/source/reference/random/performance.rst b/doc/source/reference/random/performance.rst
index 321d49454..61898ac89 100644
--- a/doc/source/reference/random/performance.rst
+++ b/doc/source/reference/random/performance.rst
@@ -10,21 +10,19 @@ Recommendation
The recommended generator for single use is
:class:`~xoroshiro128.Xoroshiro128`. The recommended generator
for use in large-scale parallel applications is
-:class:`~xorshift1024.Xorshift1024`
-where the `jump` method is used to advance the state. For very large scale
+:class:`~.xoshiro256.Xoshiro256`
+where the `jumped` method is used to advance the state. For very large scale
applications -- requiring 1,000+ independent streams,
-:class:`~pcg64.PCG64` or :class:`~threefry.ThreeFry` are
-the best choices.
+:class:`~.philox.Philox` is the best choice.
Timings
*******
-The timings below are the time in ms to produce 1,000,000 random values from a
+The timings below are the time in ns to produce 1 random value from a
specific distribution. :class:`~xoroshiro128.Xoroshiro128` is the
-fastest, followed by :class:`~xorshift1024.Xorshift1024` and
-:class:`~pcg64.PCG64`. The original :class:`~mt19937.MT19937`
-generator is much slower since it requires 2 32-bit values to equal the output
-of the faster generators.
+fastest, followed by :class:`~xorshift1024.Xorshift1024`. The original
+:class:`~mt19937.MT19937` generator is much slower since it requires 2 32-bit
+values to equal the output of the faster generators.
Integer performance has a similar ordering although `dSFMT` is slower since
it generates 53-bit floating point values rather than integer values. On the
@@ -37,40 +35,38 @@ performance gap for Exponentials is also large due to the cost of computing
the log function to invert the CDF.
.. csv-table::
- :header: ,Xoroshiro128,Xorshift1024,PCG64,DSFMT,MT19937,Philox,ThreeFry,NumPy
- :widths: 14,14,14,14,14,14,14,14,14
+ :header: ,Xoroshiro128,Xoshiro256**,Xorshift1024,MT19937,Philox,ThreeFry,NumPy
+ :widths: 14,14,14,14,14,14,14,14
- 32-bit Unsigned Ints,3.0,3.0,3.0,3.5,3.7,6.8,6.6,3.3
- 64-bit Unsigned Ints,2.6,3.0,3.1,3.4,3.8,6.9,6.6,8.8
- Uniforms,3.2,3.8,4.4,5.0,7.4,8.9,9.9,8.8
- Normals,11.0,13.9,13.7,15.8,16.9,17.8,18.8,63.0
- Exponentials,7.0,8.4,9.0,11.2,12.5,14.1,15.0,102.2
- Binomials,20.9,22.6,22.0,21.2,26.7,27.7,29.2,26.5
- Complex Normals,23.2,28.7,29.1,33.2,35.4,37.6,38.6,
- Gammas,35.3,38.6,39.2,41.3,46.7,49.4,51.2,98.8
- Laplaces,97.8,99.9,99.8,96.2,104.1,104.6,104.8,104.1
- Poissons,104.8,113.2,113.3,107.6,129.7,135.6,138.1,131.9
+ 64-bit Unsigned Ints,11.9,13.6,14.9,18.0,22.0,25.9,42.0
+ Uniforms,16.3,15.6,16.0,19.1,23.5,25.5,44.1
+ 32-bit Unsigned Ints,21.6,23.7,23.1,23.6,27.9,32.3,17.9
+ Exponentials,21.2,22.4,23.8,26.7,30.8,33.0,115.3
+ Normals,25.1,26.9,26.2,31.7,32.6,37.8,106.8
+ Binomials,72.4,73.0,71.9,77.4,80.0,83.1,101.9
+ Complex Normals,80.4,86.4,81.1,93.4,96.3,105.5,
+ Laplaces,97.0,97.4,99.6,109.8,102.3,105.1,125.3
+ Gammas,91.3,91.2,94.8,101.7,108.7,113.8,187.9
+ Poissons,136.7,137.6,139.7,161.9,171.0,181.0,265.1
The next table presents the performance relative to `xoroshiro128+` in
percentage. The overall performance was computed using a geometric mean.
.. csv-table::
- :header: ,Xorshift1024,PCG64,DSFMT,MT19937,Philox,ThreeFry,NumPy
- :widths: 14,14,14,14,14,14,14,14
+ :header: ,Xoroshiro128,Xoshiro256**,Xorshift1024,MT19937,Philox,ThreeFry
+ :widths: 14,14,14,14,14,14,14
- 32-bit Unsigned Ints,102,99,118,125,229,221,111
- 64-bit Unsigned Ints,114,116,129,143,262,248,331
- Uniforms,116,137,156,231,275,306,274
- Normals,126,124,143,153,161,170,572
- Exponentials,121,130,161,179,203,215,1467
- Binomials,108,105,101,128,133,140,127
- Complex Normals,124,125,143,153,162,166,
- Gammas,109,111,117,132,140,145,280
- Laplaces,102,102,98,106,107,107,106
- Poissons,108,108,103,124,129,132,126
- Overall,113,115,125,144,172,177,251
-
+ 64-bit Unsigned Ints,353,309,283,233,191,162
+ Uniforms,271,283,276,232,188,173
+ 32-bit Unsigned Ints,83,76,78,76,64,56
+ Exponentials,544,514,485,432,375,350
+ Normals,425,397,407,337,328,283
+ Binomials,141,140,142,132,127,123
+ Laplaces,129,129,126,114,123,119
+ Gammas,206,206,198,185,173,165
+ Poissons,194,193,190,164,155,146
+ Overall,223,215,210,186,170,156
.. note::
diff --git a/doc/source/reference/random/references.rst b/doc/source/reference/random/references.rst
deleted file mode 100644
index 0dc99868f..000000000
--- a/doc/source/reference/random/references.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-References
-----------
-
-.. [Lemire] Daniel Lemire., "Fast Random Integer Generation in an Interval",
- CoRR, Aug. 13, 2018, http://arxiv.org/abs/1805.10941.