Skip to content

Commit 67d596c

Browse files
committed
DOC: tighten up documentation, add a table of comparison
1 parent fec242a commit 67d596c

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

doc/source/reference/random/brng/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _brng:
2+
13
Basic Random Number Generators
24
------------------------------
35

@@ -12,8 +14,6 @@ access the functions provided, e.g., `numba <https://numba.pydata.org>`_.
1214

1315
Stable RNGs
1416
===========
15-
These RNGs will be included in future releases.
16-
1717

1818
.. toctree::
1919
:maxdepth: 1

doc/source/reference/random/index.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ What's New or Different
9393
.. warning::
9494

9595
The Box-Muller method used to produce NumPy's normals is no longer available
96-
in `~RandomGenerator`. It is not possible to reproduce the random values
97-
using ``RandomGenerator`` for the normal distribution or any other
98-
distribution that relies on the normal such as the gamma or student's t.
99-
Use the backward-compatible legacy generator, `~mtrand`, which fully
100-
reproduces the sequence produced by pre-1.17.0.
96+
in `~.RandomGenerator`. It is not possible to reproduce the exact random
97+
values using ``RandomGenerator`` for the normal distribution or any other
98+
distribution that relies on the normal such as the `numpy.random.gamma` or
99+
`numpy.random.standard_t`. If you require bitwise backward compatible
100+
streams, use `~.mtrand.RandomState`.
101101

102102
* The normal, exponential and gamma generators use 256-step Ziggurat
103103
methods which are 2-10 times faster than NumPy's Box-Muller or inverse CDF
@@ -120,7 +120,6 @@ What's New or Different
120120
arbitrary interval by setting ``use_masked=True`` in
121121
`~RandomGenerator.randint`.
122122

123-
124123
See :ref:`new-or-different` for a complete list of improvements and
125124
differences.
126125

doc/source/reference/random/legacy.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
.. _legacy:
2+
13
Legacy Random Generation
24
------------------------
3-
The :class:`~mtrand.RandomState` provides access to
5+
The `~mtrand.RandomState` provides access to
46
legacy generators. These all depend on Box-Muller normals or
57
inverse CDF exponentials or gammas. This class should only be used
68
if it is essential to have randoms that are identical to what
79
would have been produced by NumPy.
810

9-
:class:`~mtrand.RandomState` adds additional information
11+
`~mtrand.RandomState` adds additional information
1012
to the state which is required when using Box-Muller normals since these
1113
are produced in pairs. It is important to use
12-
:attr:`~mtrand.RandomState.get_state`
14+
`~mtrand.RandomState.get_state`
1315
when accessing the state so that these extra values are saved.
1416

1517
.. code-block:: python
@@ -46,6 +48,7 @@ Seeding and State
4648

4749
~RandomState.get_state
4850
~RandomState.set_state
51+
~RandomState.seed
4952

5053
Simple random data
5154
==================

doc/source/reference/random/new-or-different.rst

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,37 @@ What's New or Different
88
.. warning::
99

1010
The Box-Muller method used to produce NumPy's normals is no longer available
11-
in `~.RandomGenerator`. It is not possible to
12-
reproduce the exact random values using ``RandomGenerator`` for the normal
13-
distribution or any other distribution that relies on the normal such as the
14-
`numpy.random.gamma` or `numpy.random.standard_t`. If you require backward
15-
compatibility, a legacy generator, `~.legacy.
16-
LegacyGenerator`, has been created which can fully reproduce the exact byte
17-
sequence produced by legacy code.
18-
11+
in `~.RandomGenerator`. It is not possible to reproduce the exact random
12+
values using ``RandomGenerator`` for the normal distribution or any other
13+
distribution that relies on the normal such as the `numpy.random.gamma` or
14+
`numpy.random.standard_t`. If you require bitwise backward compatible
15+
streams, use `~.mtrand.RandomState`.
16+
17+
Quick comparison of legacy `mtrand <legacy>`_ to the new `generator
18+
<RandomGenerator>`
19+
20+
=================== =================== =============
21+
Feature Older Equivalent Notes
22+
------------------- ------------------- -------------
23+
`RandomGenerator` `RandomState` ``RandomGenerator`` requires a stream
24+
source, called a RandomNumberGenerator
25+
(RNG). A number of different basic
26+
`RNGs <brng>`_ exist. ``RandomState``
27+
uses only the Box- Muller method.
28+
------------------- ------------------- -------------
29+
``np.random.gen.`` ``np.random.`` Access the next values in an already-
30+
``random_sample()`` ``random_sample()`` instaniated RNG, convert them to
31+
``float64`` in the interval ``[0.0.,``
32+
`` 1.0)`` In addition to the ``size``
33+
kwarg, now supports ``dtype='d'`` or
34+
``dtype='f'``, and an ``out`` kwarg to
35+
fill a user-supplied array.
36+
37+
Many other distributions are also
38+
supported.
39+
=================== =================== =============
40+
41+
And in more detail:
1942

2043
* `~.entropy.random_entropy` provides access to the system
2144
source of randomness that is used in cryptographic applications (e.g.,

0 commit comments

Comments
 (0)