You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/reference/index.rst
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,14 +28,13 @@ Drop-in interfaces
28
28
29
29
The :mod:`mkl_random.interfaces` submodule provides drop-in replacements for standard random modules:
30
30
31
-
* :ref:`mkl_random.interfaces.numpy_random <numpy_random_interface>` - a drop-in replacement for the legacy :mod:`numpy.random` module
31
+
* :ref:`mkl_random.interfaces.numpy_random <numpy_random_interface>` - a drop-in replacement for the legacy `numpy.random<https://numpy.org/doc/stable/reference/random/legacy.html>`_ module
32
32
33
33
34
34
Patching
35
35
--------
36
36
37
-
:mod:`mkl_random` can :ref:`patch numpy.random <patching>` so that existing code calling :mod:`numpy.random`
38
-
functions can use :mod:`mkl_random` implementations.
37
+
:mod:`mkl_random` can :ref:`patch numpy.random <patching>` so that existing code calling `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_ functions can use :mod:`mkl_random` implementations.
Since the first release of :mod:`mkl_random`, NumPy introduced new classes :class:`numpy.random.Generator` and
47
48
:class:`numpy.random.BitGenerator`, while also retaining :class:`numpy.random.RandomState` for backwards
48
49
compatibility. :mod:`mkl_random`, at present, does not provide classes mirroring :class:`Generator` or
49
50
:class:`BitGenerators`.
50
51
51
-
The state of pseudo-random number generator is stored in :class:`mkl_random.RandomState` class,
52
+
.. tip::
53
+
If you want a drop-in replacement for the `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_ legacy interface,
54
+
see :ref:`interfaces`. While it is recommended users rewrite code to use :mod:`mkl_random` or :mod:`<|mkl_random.interfaces.numpy_random|>`
55
+
directly, :mod:`mkl_random` provides tools to patch `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_ so that
56
+
existing code transparently uses the MKL-backed implementations in `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_.
57
+
See :ref:`patching` for details.
58
+
59
+
The state of pseudo-random number generator is stored in :class:`mkl_random.MKLRandomState` class,
52
60
so using :mod:`mkl_random` begins with creating an instance of this class:
53
61
54
62
.. code-block:: python
55
63
:caption: Construct random number generator
56
64
57
65
import mkl_random
58
-
rs = mkl_random.RandomState(seed=1234)
66
+
rs = mkl_random.MKLRandomState(seed=1234)
59
67
60
68
Sampling from difference probability distribution is done by calling the class methods on the constructed instance:
61
69
@@ -75,7 +83,7 @@ Here is an example of estimating value of :math:`\pi` by using Monte-Carlo metho
75
83
import numpy as np
76
84
import mkl_random
77
85
78
-
rs = mkl_random.RandomState(seed=1234)
86
+
rs = mkl_random.MKLRandomState(seed=1234)
79
87
80
88
sample_size =10**8
81
89
batch_size =10**6
@@ -110,7 +118,7 @@ distributions of interest.
110
118
`True random generator <https://en.wikipedia.org/wiki/Hardware_random_number_generator>`_ relies on
111
119
laws of physics to provide those, leveraging dedicated hardware providing a source of entropy.
112
120
113
-
`Psuedo-random generator <https://en.wikipedia.org/wiki/Pseudorandom_number_generator>`_ is an algorithm that outputs a sequence that emulates true randomness.
121
+
`Pseudo-random generator <https://en.wikipedia.org/wiki/Pseudorandom_number_generator>`_ is an algorithm that outputs a sequence that emulates true randomness.
114
122
The quality of emulation is tested statistically through a battery of test, e.g. `Diehard tests <https://en.wikipedia.org/wiki/Diehard_tests>`_.
115
123
These tests check if various statistical tests can separate the pseudo-random sequence from a true random one.
0 commit comments