summaryrefslogtreecommitdiff
path: root/doc/source/reference/random
diff options
context:
space:
mode:
authorRobert Kern <robert.kern@gmail.com>2019-06-27 15:45:35 -0700
committerRobert Kern <robert.kern@gmail.com>2019-06-27 15:45:35 -0700
commit5b0d1b56e334bc9b83e1ba6bf5a557788a8fd5bf (patch)
tree88db7356daf733d972c1053fbf5614af0d3b0b19 /doc/source/reference/random
parent4bdaa9b7bafcdc2f81df18057dea7619cfeeec2c (diff)
downloadnumpy-5b0d1b56e334bc9b83e1ba6bf5a557788a8fd5bf.tar.gz
DOC: clean up examples.
Diffstat (limited to 'doc/source/reference/random')
-rw-r--r--doc/source/reference/random/bit_generators/index.rst2
-rw-r--r--doc/source/reference/random/legacy.rst17
2 files changed, 10 insertions, 9 deletions
diff --git a/doc/source/reference/random/bit_generators/index.rst b/doc/source/reference/random/bit_generators/index.rst
index 24ac34e21..35d9e5d09 100644
--- a/doc/source/reference/random/bit_generators/index.rst
+++ b/doc/source/reference/random/bit_generators/index.rst
@@ -81,7 +81,7 @@ user, which is up to you.
# If the user did not provide a seed, it should return `None`.
seed = get_user_seed()
ss = SeedSequence(seed)
- print(f'seed = {ss.entropy}')
+ print('seed = {}'.format(ss.entropy))
bg = PCG64(ss)
.. end_block
diff --git a/doc/source/reference/random/legacy.rst b/doc/source/reference/random/legacy.rst
index 1f022180f..04d4d3569 100644
--- a/doc/source/reference/random/legacy.rst
+++ b/doc/source/reference/random/legacy.rst
@@ -23,27 +23,28 @@ Although we provide the `~mt19937.MT19937` BitGenerator for use independent of
rather than the legacy seeding algorithm. `~mtrand.RandomState` will use the
legacy seeding algorithm. The methods to use the legacy seeding algorithm are
currently private as the main reason to use them is just to implement
-`~mtrand.RandomState`.
+`~mtrand.RandomState`. However, one can reset the state of `~mt19937.MT19937`
+using the state of the `~mtrand.RandomState`:
.. code-block:: python
from numpy.random import MT19937
from numpy.random import RandomState
- # Use same seed
rs = RandomState(12345)
- mt19937 = MT19937(12345)
- lg = RandomState(mt19937)
+ mt19937 = MT19937()
+ mt19937.state = rs.get_state()
+ rs2 = RandomState(mt19937)
- # Different output, sorry.
+ # Same output
rs.standard_normal()
- lg.standard_normal()
+ rs2.standard_normal()
rs.random()
- lg.random()
+ rs2.random()
rs.standard_exponential()
- lg.standard_exponential()
+ rs2.standard_exponential()
.. currentmodule:: numpy.random.mtrand