File tree 2 files changed +8
-8
lines changed
doc/source/reference/random 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,13 @@ the random values are generated by `~xoroshiro128.Xoroshiro128`. The
52
52
53
53
54
54
Seeds can be passed to any of the BitGenerators. Here `mt19937.MT19937 ` is used
55
- and the `` Generator `` is accessed via the attribute ` mt19937.MT19937 .
56
- generator `.
55
+ and is the wrapped with a ` ~.Generator ` .
56
+
57
57
58
58
.. code-block :: python
59
59
60
- from numpy.random import MT19937
61
- rg = MT19937(12345 ).generator
60
+ from numpy.random import Generator, MT19937
61
+ rg = Generator( MT19937(12345 ))
62
62
rg.standard_normal()
63
63
64
64
@@ -78,7 +78,7 @@ bit generator-provided stream and transforms them into more useful
78
78
distributions, e.g., simulated normal random values. This structure allows
79
79
alternative bit generators to be used with little code duplication.
80
80
81
- The `` Generator ` ` is the user-facing object
81
+ The `~. Generator ` is the user-facing object
82
82
that is nearly identical to :class: `~.RandomState `. The canonical
83
83
method to initialize a generator passes a `~mt19937.MT19937 ` bit generator, the
84
84
underlying bit generator in Python -- as the sole argument. Note that the bit
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ are reproducible in the sense that the same seed will produce the same outputs.
16
16
17
17
.. code-block :: ipython
18
18
19
- from numpy.random import Xorshift1024
19
+ from numpy.random import Generator, Xorshift1024
20
20
import multiprocessing
21
21
import concurrent.futures
22
22
import numpy as np
@@ -88,7 +88,7 @@ The single threaded call directly uses the PRNG.
88
88
.. code-block :: ipython
89
89
90
90
In [5]: values = np.empty(10000000)
91
- ...: rg = Xorshift1024().generator
91
+ ...: rg = Generator( Xorshift1024())
92
92
...: %timeit rg.standard_normal(out=values)
93
93
94
94
99.6 ms ± 222 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
@@ -99,7 +99,7 @@ that does not use an existing array due to array creation overhead.
99
99
100
100
.. code-block :: ipython
101
101
102
- In [6]: rg = Xorshift1024().generator
102
+ In [6]: rg = Generator( Xorshift1024())
103
103
...: %timeit rg.standard_normal(10000000)
104
104
105
105
125 ms ± 309 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
You can’t perform that action at this time.
0 commit comments