Skip to content

Commit a58a546

Browse files
committed
DOC: Updated remaining links in random folder
This should clean up the rest of the internal links in the random folder of reference. Let me know if this is too many at once to review, and I'll batch them in smaller groups. [skip azp] [skip actions] [skip cirrus]
1 parent aa0cc04 commit a58a546

File tree

13 files changed

+71
-71
lines changed

13 files changed

+71
-71
lines changed

doc/source/reference/c-api/coremath.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NumPy core math library
22
=======================
33

4-
The numpy core math library ('npymath') is a first step in this direction. This
4+
The numpy core math library (``npymath``) is a first step in this direction. This
55
library contains most math-related C99 functionality, which can be used on
66
platforms where C99 is not well supported. The core math functions have the
77
same API as the C99 ones, except for the ``npy_*`` prefix.
@@ -304,7 +304,7 @@ Linking against the core math library in an extension
304304
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305305

306306
To use the core math library that NumPy ships as a static library in your own
307-
Python extension, you need to add the npymath compile and link options to your
307+
Python extension, you need to add the ``npymath`` compile and link options to your
308308
extension. The exact steps to take will depend on the build system you are using.
309309
The generic steps to take are:
310310

doc/source/reference/distutils.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Packaging (:mod:`numpy.distutils`)
1414
.. warning::
1515

1616
Note that ``setuptools`` does major releases often and those may contain
17-
changes that break ``numpy.distutils``, which will *not* be updated anymore
17+
changes that break :mod:`numpy.distutils`, which will *not* be updated anymore
1818
for new ``setuptools`` versions. It is therefore recommended to set an
1919
upper version bound in your build configuration for the last known version
2020
of ``setuptools`` that works with your build.

doc/source/reference/random/compatibility.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ outside of NumPy's control that limit our ability to guarantee much more than
2222
this. For example, different CPUs implement floating point arithmetic
2323
differently, and this can cause differences in certain edge cases that cascade
2424
to the rest of the stream. `Generator.multivariate_normal`, for another
25-
example, uses a matrix decomposition from ``numpy.linalg``. Even on the same
25+
example, uses a matrix decomposition from `numpy.linalg`. Even on the same
2626
platform, a different build of ``numpy`` may use a different version of this
2727
matrix decomposition algorithm from the LAPACK that it links to, causing
2828
`Generator.multivariate_normal` to return completely different (but equally

doc/source/reference/random/extending.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Extending
66
=========
77
The BitGenerators have been designed to be extendable using standard tools for
8-
high-performance Python -- numba and Cython. The `~Generator` object can also
8+
high-performance Python -- numba and Cython. The `Generator` object can also
99
be used with user-provided BitGenerators as long as these export a small set of
1010
required functions.
1111

@@ -81,7 +81,7 @@ directly from the ``_generator`` shared object, using the `BitGenerator.cffi` in
8181

8282
New BitGenerators
8383
-----------------
84-
`~Generator` can be used with user-provided `~BitGenerator`\ s. The simplest
84+
`Generator` can be used with user-provided `BitGenerator`\ s. The simplest
8585
way to write a new BitGenerator is to examine the pyx file of one of the
8686
existing BitGenerators. The key structure that must be provided is the
8787
``capsule`` which contains a ``PyCapsule`` to a struct pointer of type
@@ -102,7 +102,7 @@ used by the BitGenerators. The next three are function pointers which return
102102
the next 64- and 32-bit unsigned integers, the next random double and the next
103103
raw value. This final function is used for testing and so can be set to
104104
the next 64-bit unsigned integer function if not needed. Functions inside
105-
``Generator`` use this structure as in
105+
`Generator` use this structure as in
106106

107107
.. code-block:: c
108108

doc/source/reference/random/multithreading.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ that does not use an existing array due to array creation overhead.
104104
105105
Out[6]: 125 ms ± 309 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
106106
107-
Note that if `threads` is not set by the user, it will be determined by
108-
`multiprocessing.cpu_count()`.
107+
Note that if ``threads`` is not set by the user, it will be determined by
108+
``multiprocessing.cpu_count()``.
109109

110110
.. code-block:: ipython
111111

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ implementations.
1212
================== ==================== =============
1313
Feature Older Equivalent Notes
1414
------------------ -------------------- -------------
15-
`~.Generator` `~.RandomState` ``Generator`` requires a stream
15+
`Generator` `RandomState` `Generator` requires a stream
1616
source, called a `BitGenerator`
1717
A number of these are provided.
18-
``RandomState`` uses
19-
the Mersenne Twister `~.MT19937` by
18+
`RandomState` uses
19+
the Mersenne Twister `MT19937` by
2020
default, but can also be instantiated
2121
with any BitGenerator.
2222
------------------ -------------------- -------------
23-
``random`` ``random_sample``, Access the values in a BitGenerator,
24-
``rand`` convert them to ``float64`` in the
23+
`random` `random_sample`, Access the values in a BitGenerator,
24+
`rand` convert them to ``float64`` in the
2525
interval ``[0.0.,`` `` 1.0)``.
2626
In addition to the ``size`` kwarg, now
2727
supports ``dtype='d'`` or ``dtype='f'``,
@@ -31,16 +31,16 @@ Feature Older Equivalent Notes
3131
Many other distributions are also
3232
supported.
3333
------------------ -------------------- -------------
34-
``integers`` ``randint``, Use the ``endpoint`` kwarg to adjust
35-
``random_integers`` the inclusion or exclusion of the
34+
`integers` `randint`, Use the ``endpoint`` kwarg to adjust
35+
`random_integers` the inclusion or exclusion of the
3636
``high`` interval endpoint
3737
================== ==================== =============
3838

3939
* The normal, exponential and gamma generators use 256-step Ziggurat
4040
methods which are 2-10 times faster than NumPy's default implementation in
4141
`~.Generator.standard_normal`, `~.Generator.standard_exponential` or
4242
`~.Generator.standard_gamma`. Because of the change in algorithms, it is not
43-
possible to reproduce the exact random values using ``Generator`` for these
43+
possible to reproduce the exact random values using `Generator` for these
4444
distributions or any distribution method that relies on them.
4545

4646
.. ipython:: python
@@ -63,8 +63,8 @@ Feature Older Equivalent Notes
6363
6464
* `~.Generator.integers` is now the canonical way to generate integer
6565
random numbers from a discrete uniform distribution. This replaces both
66-
``randint`` and the deprecated ``random_integers``.
67-
* The ``rand`` and ``randn`` methods are only available through the legacy
66+
`randint` and the deprecated `random_integers`.
67+
* The `rand` and `randn` methods are only available through the legacy
6868
`~.RandomState`.
6969
* `Generator.random` is now the canonical way to generate floating-point
7070
random numbers, which replaces `RandomState.random_sample`,

doc/source/reference/random/parallel.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@ or distributed).
1313
------------------------
1414

1515
NumPy allows you to spawn new (with very high probability) independent
16-
`~BitGenerator` and `~Generator` instances via their ``spawn()`` method.
17-
This spawning is implemented by the `~SeedSequence` used for initializing
16+
`BitGenerator` and `Generator` instances via their ``spawn()`` method.
17+
This spawning is implemented by the `SeedSequence` used for initializing
1818
the bit generators random stream.
1919

20-
`~SeedSequence` `implements an algorithm`_ to process a user-provided seed,
20+
`SeedSequence` `implements an algorithm`_ to process a user-provided seed,
2121
typically as an integer of some size, and to convert it into an initial state for
22-
a `~BitGenerator`. It uses hashing techniques to ensure that low-quality seeds
22+
a `BitGenerator`. It uses hashing techniques to ensure that low-quality seeds
2323
are turned into high quality initial states (at least, with very high
2424
probability).
2525

26-
For example, `MT19937` has a state consisting of 624
27-
`uint32` integers. A naive way to take a 32-bit integer seed would be to just set
26+
For example, `MT19937` has a state consisting of 624 ``uint32``
27+
integers. A naive way to take a 32-bit integer seed would be to just set
2828
the last element of the state to the 32-bit seed and leave the rest 0s. This is
2929
a valid state for `MT19937`, but not a good one. The Mersenne Twister
3030
algorithm `suffers if there are too many 0s`_. Similarly, two adjacent 32-bit
3131
integer seeds (i.e. ``12345`` and ``12346``) would produce very similar
3232
streams.
3333

34-
`~SeedSequence` avoids these problems by using successions of integer hashes
34+
`SeedSequence` avoids these problems by using successions of integer hashes
3535
with good `avalanche properties`_ to ensure that flipping any bit in the input
3636
has about a 50% chance of flipping any bit in the output. Two input seeds that
3737
are very close to each other will produce initial states that are very far
3838
from each other (with very high probability). It is also constructed in such
3939
a way that you can provide arbitrary-sized integers or lists of integers.
40-
`~SeedSequence` will take all of the bits that you provide and mix them
41-
together to produce however many bits the consuming `~BitGenerator` needs to
40+
`SeedSequence` will take all of the bits that you provide and mix them
41+
together to produce however many bits the consuming `BitGenerator` needs to
4242
initialize itself.
4343

4444
These properties together mean that we can safely mix together the usual
45-
user-provided seed with simple incrementing counters to get `~BitGenerator`
45+
user-provided seed with simple incrementing counters to get `BitGenerator`
4646
states that are (to very high probability) independent of each other. We can
4747
wrap this together into an API that is easy to use and difficult to misuse.
48-
Note that while `~SeedSequence` attempts to solve many of the issues related to
48+
Note that while `SeedSequence` attempts to solve many of the issues related to
4949
user-provided small seeds, we still :ref:`recommend<recommend-secrets-randbits>`
5050
using :py:func:`secrets.randbits` to generate seeds with 128 bits of entropy to
5151
avoid the remaining biases introduced by human-chosen seeds.
@@ -62,7 +62,7 @@ avoid the remaining biases introduced by human-chosen seeds.
6262
6363
.. end_block
6464
65-
For convenience the direct use of `~SeedSequence` is not necessary.
65+
For convenience the direct use of `SeedSequence` is not necessary.
6666
The above ``streams`` can be spawned directly from a parent generator
6767
via `~Generator.spawn`:
6868

@@ -74,7 +74,7 @@ via `~Generator.spawn`:
7474
.. end_block
7575
7676
Child objects can also spawn to make grandchildren, and so on.
77-
Each child has a `~SeedSequence` with its position in the tree of spawned
77+
Each child has a `SeedSequence` with its position in the tree of spawned
7878
child objects mixed in with the user-provided seed to generate independent
7979
(with very high probability) streams.
8080

@@ -92,7 +92,7 @@ Python has increasingly-flexible mechanisms for parallelization available, and
9292
this scheme fits in very well with that kind of use.
9393

9494
Using this scheme, an upper bound on the probability of a collision can be
95-
estimated if one knows the number of streams that you derive. `~SeedSequence`
95+
estimated if one knows the number of streams that you derive. `SeedSequence`
9696
hashes its inputs, both the seed and the spawn-tree-path, down to a 128-bit
9797
pool by default. The probability that there is a collision in
9898
that pool, pessimistically-estimated ([1]_), will be about :math:`n^2*2^{-128}` where
@@ -110,7 +110,7 @@ territory ([2]_).
110110
.. [2] In this calculation, we can mostly ignore the amount of numbers drawn from each
111111
stream. See :ref:`upgrading-pcg64` for the technical details about
112112
`PCG64`. The other PRNGs we provide have some extra protection built in
113-
that avoids overlaps if the `~SeedSequence` pools differ in the
113+
that avoids overlaps if the `SeedSequence` pools differ in the
114114
slightest bit. `PCG64DXSM` has :math:`2^{127}` separate cycles
115115
determined by the seed in addition to the position in the
116116
:math:`2^{128}` long period for each cycle, so one has to both get on or
@@ -133,7 +133,7 @@ territory ([2]_).
133133
Sequence of integer seeds
134134
-------------------------
135135

136-
As discussed in the previous section, `~SeedSequence` can not only take an
136+
As discussed in the previous section, `SeedSequence` can not only take an
137137
integer seed, it can also take an arbitrary-length sequence of (non-negative)
138138
integers. If one exercises a little care, one can use this feature to design
139139
*ad hoc* schemes for getting safe parallel PRNG streams with similar safety
@@ -164,7 +164,7 @@ integer in a list.
164164
This can be used to replace a number of unsafe strategies that have been used
165165
in the past which try to combine the root seed and the ID back into a single
166166
integer seed value. For example, it is common to see users add the worker ID to
167-
the root seed, especially with the legacy `~RandomState` code.
167+
the root seed, especially with the legacy `RandomState` code.
168168

169169
.. code-block:: python
170170
@@ -253,13 +253,13 @@ are listed below.
253253
+-----------------+-------------------------+-------------------------+-------------------------+
254254
| BitGenerator | Period | Jump Size | Bits per Draw |
255255
+=================+=========================+=========================+=========================+
256-
| MT19937 | :math:`2^{19937}-1` | :math:`2^{128}` | 32 |
256+
| `MT19937` | :math:`2^{19937}-1` | :math:`2^{128}` | 32 |
257257
+-----------------+-------------------------+-------------------------+-------------------------+
258-
| PCG64 | :math:`2^{128}` | :math:`~2^{127}` ([3]_) | 64 |
258+
| `PCG64` | :math:`2^{128}` | :math:`~2^{127}` ([3]_) | 64 |
259259
+-----------------+-------------------------+-------------------------+-------------------------+
260-
| PCG64DXSM | :math:`2^{128}` | :math:`~2^{127}` ([3]_) | 64 |
260+
| `PCG64DXSM` | :math:`2^{128}` | :math:`~2^{127}` ([3]_) | 64 |
261261
+-----------------+-------------------------+-------------------------+-------------------------+
262-
| Philox | :math:`2^{256}` | :math:`2^{128}` | 64 |
262+
| `Philox` | :math:`2^{256}` | :math:`2^{128}` | 64 |
263263
+-----------------+-------------------------+-------------------------+-------------------------+
264264

265265
.. [3] The jump size is :math:`(\phi-1)*2^{128}` where :math:`\phi` is the

doc/source/reference/random/performance.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ even on 32-bit processes, this is your choice.
2424

2525
`MT19937` `fails some statistical tests`_ and is not especially
2626
fast compared to modern PRNGs. For these reasons, we mostly do not recommend
27-
using it on its own, only through the legacy `~.RandomState` for
27+
using it on its own, only through the legacy `RandomState` for
2828
reproducing old results. That said, it has a very long history as a default in
2929
many systems.
3030

doc/source/reference/random/upgrading-pcg64.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.. currentmodule:: numpy.random
44

5-
Upgrading ``PCG64`` with ``PCG64DXSM``
5+
Upgrading `PCG64` with `PCG64DXSM`
66
======================================
77

88
Uses of the `PCG64` `BitGenerator` in a massively-parallel context have been

numpy/random/_mt19937.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ cdef class MT19937(BitGenerator):
6767
6868
Notes
6969
-----
70-
``MT19937`` provides a capsule containing function pointers that produce
70+
`MT19937` provides a capsule containing function pointers that produce
7171
doubles, and unsigned 32 and 64- bit integers [1]_. These are not
72-
directly consumable in Python and must be consumed by a ``Generator``
72+
directly consumable in Python and must be consumed by a `Generator`
7373
or similar object that supports low-level access.
7474
7575
The Python stdlib module "random" also contains a Mersenne Twister
7676
pseudo-random number generator.
7777
7878
**State and Seeding**
7979
80-
The ``MT19937`` state vector consists of a 624-element array of
80+
The `MT19937` state vector consists of a 624-element array of
8181
32-bit unsigned integers plus a single integer value between 0 and 624
8282
that indexes the current position within the main array.
8383
@@ -111,7 +111,7 @@ cdef class MT19937(BitGenerator):
111111
112112
**Compatibility Guarantee**
113113
114-
``MT19937`` makes a guarantee that a fixed seed will always produce
114+
`MT19937` makes a guarantee that a fixed seed will always produce
115115
the same random integer stream.
116116
117117
References

0 commit comments

Comments
 (0)