Skip to content

Commit e8dfd47

Browse files
committed
Merge pull request #25 from bashtage/gh-pages
DOC: Improve documentation
2 parents 0c41f8d + f11420b commit e8dfd47

File tree

11 files changed

+105
-53
lines changed

11 files changed

+105
-53
lines changed

doc/source/entropy.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
System Entropy
2+
==============
3+
4+
.. autofunction:: randomstate.entropy.random_entropy

doc/source/index.rst

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,57 @@
11
randomstate's documentation
22
===========================
3+
This package contains a drop-in replacements for the NumPy RandomState object
4+
that change the core random number generator.
35

4-
RnadomPseudo Random Number Generator Documentation:
6+
What's New or Different
7+
=======================
8+
* ``random_uintegers`` produces either 32-bit or 64-bit unsigned integers.
9+
These are at thte core of most PRNGs and so they are directly exposed.
10+
* ``randomstate.entropy.random_entropy`` provides access to the system
11+
source of randomness that is used in cryptographic applications (e.g.,
12+
``/dev/urandom`` on Unix).
13+
* The normal generator supports a 256-step ziggurat method which is 2-6 times
14+
faster than NumPy's ``standard_normal``. This generator can be accessed using
15+
16+
.. code-block:: python
17+
18+
from randomstate import standard_normal
19+
standard_normal(100000, method='zig')
20+
21+
22+
Supported Generators
23+
====================
24+
The main innovation is the includion of a number of alterntive pseudo random number
25+
generators, 'in addition' to the standard PRNG in NumPy. The included PRNGs are:
26+
27+
* MT19937 - The standard NumPy generator. Produces identical results to NumPy
28+
using the same seed/state. See `NumPy's documentation`_.
29+
* dSFMT - A SSE2 enables version of the MT19937 generator. Theoretically the
30+
same, but with a different state and so it is not possible to produce an
31+
sequence identical to MT19937. See the `dSFMT authors' page`_.
32+
* XorShit128+ and XorShift1024* - Vast fast generators based on the XSadd
33+
generator. These generators can be rapidly 'jumped' and so can be used in
34+
parallel applications. See the `xorshift authors' page`_.
35+
* PCG-32 and PCG-64 - Fast generators that support many parallel streams and
36+
can be advanced by an arbitrary amount. PCG-32 only as a period of :math:`2^{64}`
37+
while PCG-64 has a period of :math:`2^{128}`. See the `PCG author's page`_.
38+
* Multiplicative Lagged Fibbonacci Generator MLFG(1279, 861, \*) - A directly
39+
implemented multiplicative lagged fibbonacci generator with a very large
40+
period and good performance. Future plans include multiple stream support.
41+
See the `wiki page on Fibonacci generators`_.
42+
* MRG32K3A - a classic and popular generator by L'Ecuyer. Future plans
43+
include multiple stream support. See the `MRG32K3A author's page`_. Lower
44+
performance than more modern generators.
45+
46+
.. _`NumPy's documentation`: http://docs.scipy.org/doc/numpy/reference/routines.random.html
47+
.. _`dSFMT authors' page`: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/
48+
.. _`xorshift authors' page`: http://xorshift.di.unimi.it/
49+
.. _`PCG author's page`: http://www.pcg-random.org/
50+
.. _`wiki page on Fibonacci generators`: https://en.wikipedia.org/wiki/Lagged_Fibonacci_generator
51+
.. _`MRG32K3A author's page`: http://simul.iro.umontreal.ca/
52+
53+
54+
RandomState Pseudo Random Number Generator Documentation:
555

656
.. toctree::
757
:maxdepth: 2
@@ -14,10 +64,8 @@ RnadomPseudo Random Number Generator Documentation:
1464
PCG-64 <pcg64>
1565
MLFG <mlfg>
1666
MRG32K3A <mrg32k3a>
67+
Readying System Entropy <entropy>
1768

18-
Other Functions
19-
===============
20-
.. autofunction:: randomstate.entropy.random_entropy
2169

2270
Indices and tables
2371
==================

doc/source/mlfg.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
MLFG(1279, 861, *) Randomstate
2-
===============================
1+
MLFG(1279, 861, \*) Randomstate
2+
================================
33

44
.. py:currentmodule:: randomstate.prng.mlfg_1279_861
55

randomstate/interface.pyx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ cdef class RandomState:
178178
179179
Seed the generator.
180180
181-
This method is called when `RandomState` is initialized. It can be
182-
called again to re-seed the generator. For details, see `RandomState`.
181+
This method is called when ``RandomState`` is initialized. It can be
182+
called again to re-seed the generator. For details, see ``RandomState``.
183183
184184
Parameters
185185
----------
186186
seed : int or array_like, optional
187-
Seed for `RandomState`.
187+
Seed for ``RandomState``.
188188
Must be convertible to 32 bit unsigned integers.
189189
190190
See Also
@@ -219,13 +219,13 @@ cdef class RandomState:
219219
220220
Seed the generator.
221221
222-
This method is called when `RandomState` is initialized. It can be
223-
called again to re-seed the generator. For details, see `RandomState`.
222+
This method is called when ``RandomState`` is initialized. It can be
223+
called again to re-seed the generator. For details, see ``RandomState``.
224224
225225
Parameters
226226
----------
227227
val : int, optional
228-
Seed for `RandomState`.
228+
Seed for ``RandomState``.
229229
230230
Notes
231231
-----
@@ -253,13 +253,13 @@ cdef class RandomState:
253253
254254
Seed the generator.
255255
256-
This method is called when `RandomState` is initialized. It can be
257-
called again to re-seed the generator. For details, see `RandomState`.
256+
This method is called when ``RandomState`` is initialized. It can be
257+
called again to re-seed the generator. For details, see ``RandomState``.
258258
259259
Parameters
260260
----------
261261
val : int, optional
262-
Seed for `RandomState`.
262+
Seed for ``RandomState``.
263263
inc : int, optional
264264
Increment to use for producing multiple streams
265265
@@ -363,7 +363,7 @@ cdef class RandomState:
363363
364364
Return a tuple representing the internal state of the generator.
365365
366-
For more details, see `set_state`.
366+
For more details, see ``set_state``.
367367
368368
Parameters
369369
----------
@@ -386,7 +386,7 @@ cdef class RandomState:
386386
387387
Notes
388388
-----
389-
`set_state` and `get_state` are not needed to work with any of the
389+
``set_state`` and ``get_state`` are not needed to work with any of the
390390
random distributions in NumPy. If the internal state is manually altered,
391391
the user should know exactly what he/she is doing.
392392
@@ -410,7 +410,7 @@ cdef class RandomState:
410410
411411
Return a tuple representing the internal state of the generator.
412412
413-
For more details, see `set_state`.
413+
For more details, see ``set_state``.
414414
415415
Returns
416416
-------
@@ -428,7 +428,7 @@ cdef class RandomState:
428428
429429
Notes
430430
-----
431-
`set_state` and `get_state` are not needed to work with any of the
431+
``set_state`` and ``get_state`` are not needed to work with any of the
432432
random distributions in NumPy. If the internal state is manually altered,
433433
the user should know exactly what he/she is doing.
434434
@@ -471,7 +471,7 @@ cdef class RandomState:
471471
472472
Notes
473473
-----
474-
`set_state` and `get_state` are not needed to work with any of the
474+
``set_state`` and ``get_state`` are not needed to work with any of the
475475
random distributions in NumPy. If the internal state is manually altered,
476476
the user should know exactly what he/she is doing.
477477
@@ -559,7 +559,7 @@ cdef class RandomState:
559559
560560
Results are from the "continuous uniform" distribution over the
561561
stated interval. To sample :math:`Unif[a, b), b > a` multiply
562-
the output of `random_sample` by `(b-a)` and add `a`::
562+
the output of ``random_sample`` by `(b-a)` and add `a`::
563563
564564
(b - a) * random_sample() + a
565565

randomstate/shims/dSFMT/dSFMT.pxi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ RandomState(seed=None)
8484
8585
Container for the SIMD-based Mersenne Twister pseudo-random number generator.
8686
87-
`dSFMT.RandomState` exposes a number of methods for generating random
87+
``dSFMT.RandomState`` exposes a number of methods for generating random
8888
numbers drawn from a variety of probability distributions. In addition to the
8989
distribution-specific arguments, each method takes a keyword argument
9090
`size` that defaults to ``None``. If `size` is ``None``, then a single
@@ -105,7 +105,7 @@ Parameters
105105
seed : {None, int}, optional
106106
Random seed initializing the pseudo-random number generator.
107107
Can be an integer in [0, 2**32] or ``None`` (the default).
108-
If `seed` is ``None``, then `dSFMT.RandomState` will try to read
108+
If `seed` is ``None``, then ``dSFMT.RandomState`` will try to read
109109
entropy from ``/dev/urandom`` (or the Windows analogue) if available to
110110
produce a 64-bit seed. If unavailable, the a 64-bit hash of the time
111111
and process ID is used.

randomstate/shims/mrg32k3a/mrg32k3a.pxi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ MRG32K3A is a 32-bit implementation of L'Ecuyer's combined multiple
5555
recursive generator ([1]_, [2]_). MRG32K3A has a period of 2**191 and
5656
supports multiple streams (NOT IMPLEMENTED YET).
5757
58-
`mrg32k3a.RandomState` exposes a number of methods for generating random
58+
``mrg32k3a.RandomState`` exposes a number of methods for generating random
5959
numbers drawn from a variety of probability distributions. In addition to the
6060
distribution-specific arguments, each method takes a keyword argument
6161
`size` that defaults to ``None``. If `size` is ``None``, then a single
@@ -64,10 +64,10 @@ array filled with generated values is returned. If `size` is a tuple,
6464
then an array with that shape is filled and returned.
6565
6666
*No Compatibility Guarantee*
67-
'mrg32k3a.RandomState' does not make a guarantee that a fixed seed and a
68-
fixed series of calls to 'mrg32k3a.RandomState' methods using the same
67+
``mrg32k3a.RandomState`` does not make a guarantee that a fixed seed and a
68+
fixed series of calls to ``mrg32k3a.RandomState`` methods using the same
6969
parameters will always produce the same results. This is different from
70-
'numpy.random.RandomState' guarantee. This is done to simplify improving
70+
``numpy.random.RandomState`` guarantee. This is done to simplify improving
7171
random number generators. To ensure identical results, you must use the
7272
same release version.
7373
@@ -76,7 +76,7 @@ Parameters
7676
seed : {None, int}, optional
7777
Random seed initializing the pseudo-random number generator.
7878
Can be an integer in [0, 2**64] or ``None`` (the default).
79-
If `seed` is ``None``, then `mrg32k3a.RandomState` will try to read data
79+
If `seed` is ``None``, then ``mrg32k3a.RandomState`` will try to read data
8080
from ``/dev/urandom`` (or the Windows analogue) if available or seed from
8181
the clock otherwise.
8282

randomstate/shims/pcg-32/pcg-32.pxi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ PCG-32 is a 64-bit implementation of O'Neill's permutation congruential
4747
generator ([1]_, [2]_). PCG-32 has a period of 2**64 and supports advancing
4848
an arbitrary number of steps as well as 2**63 streams.
4949
50-
`pcg32.RandomState` exposes a number of methods for generating random
50+
``pcg32.RandomState`` exposes a number of methods for generating random
5151
numbers drawn from a variety of probability distributions. In addition to the
5252
distribution-specific arguments, each method takes a keyword argument
5353
`size` that defaults to ``None``. If `size` is ``None``, then a single
@@ -56,10 +56,10 @@ array filled with generated values is returned. If `size` is a tuple,
5656
then an array with that shape is filled and returned.
5757
5858
*No Compatibility Guarantee*
59-
'pcg32.RandomState' does not make a guarantee that a fixed seed and a
60-
fixed series of calls to 'pcg32.RandomState' methods using the same
59+
``pcg32.RandomState`` does not make a guarantee that a fixed seed and a
60+
fixed series of calls to ``pcg32.RandomState`` methods using the same
6161
parameters will always produce the same results. This is different from
62-
'numpy.random.RandomState' guarantee. This is done to simplify improving
62+
``numpy.random.RandomState`` guarantee. This is done to simplify improving
6363
random number generators. To ensure identical results, you must use the
6464
same release version.
6565
@@ -68,7 +68,7 @@ Parameters
6868
seed : {None, long}, optional
6969
Random seed initializing the pseudo-random number generator.
7070
Can be an integer in [0, 2**64] or ``None`` (the default).
71-
If `seed` is ``None``, then `xorshift1024.RandomState` will try to read data
71+
If `seed` is ``None``, then ``pcg32.RandomState`` will try to read data
7272
from ``/dev/urandom`` (or the Windows analogue) if available or seed from
7373
the clock otherwise.
7474
inc : {None, int}, optional

randomstate/shims/pcg-64/pcg-64-docstring.pxi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PCG-64 is a 128-bit implementation of O'Neill's permutation congruential
77
generator ([1]_, [2]_). PCG-64 has a period of 2**128 and supports advancing
88
an arbitrary number of steps as well as 2**127 streams.
99
10-
`pcg64.RandomState` exposes a number of methods for generating random
10+
``pcg64.RandomState`` exposes a number of methods for generating random
1111
numbers drawn from a variety of probability distributions. In addition to the
1212
distribution-specific arguments, each method takes a keyword argument
1313
`size` that defaults to ``None``. If `size` is ``None``, then a single
@@ -16,10 +16,10 @@ array filled with generated values is returned. If `size` is a tuple,
1616
then an array with that shape is filled and returned.
1717
1818
*No Compatibility Guarantee*
19-
'pcg64.RandomState' does not make a guarantee that a fixed seed and a
20-
fixed series of calls to 'pcg64.RandomState' methods using the same
19+
``pcg64.RandomState`` does not make a guarantee that a fixed seed and a
20+
fixed series of calls to ``pcg64.RandomState`` methods using the same
2121
parameters will always produce the same results. This is different from
22-
'numpy.random.RandomState' guarantee. This is done to simplify improving
22+
``numpy.random.RandomState`` guarantee. This is done to simplify improving
2323
random number generators. To ensure identical results, you must use the
2424
same release version.
2525
@@ -28,7 +28,7 @@ Parameters
2828
seed : {None, long}, optional
2929
Random seed initializing the pseudo-random number generator.
3030
Can be an integer in [0, 2**128] or ``None`` (the default).
31-
If `seed` is ``None``, then `xorshift1024.RandomState` will try to read data
31+
If `seed` is ``None``, then ``pcg64.RandomState`` will try to read data
3232
from ``/dev/urandom`` (or the Windows analogue) if available or seed from
3333
the clock otherwise.
3434
inc : {None, int}, optional

randomstate/shims/random-kit/random-kit.pxi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RandomState(seed=None)
5454
5555
Container for the Mersenne Twister pseudo-random number generator.
5656
57-
`mt19937.RandomState` exposes a number of methods for generating random
57+
``mt19937.RandomState`` exposes a number of methods for generating random
5858
numbers drawn from a variety of probability distributions. In addition to the
5959
distribution-specific arguments, each method takes a keyword argument
6060
`size` that defaults to ``None``. If `size` is ``None``, then a single
@@ -63,9 +63,9 @@ array filled with generated values is returned. If `size` is a tuple,
6363
then an array with that shape is filled and returned.
6464
6565
*Compatibility Guarantee*
66-
'mt19937.RandomState' is identical to 'numpy.random.RandomState' and
66+
``mt19937.RandomState`` is identical to ``numpy.random.RandomState`` and
6767
makes the same compatability guarantee. A fixed seed and a fixed series of
68-
calls to 'mt19937.RandomState' methods using the same parameters will always
68+
calls to ``mt19937.RandomState`` methods using the same parameters will always
6969
produce the same results up to roundoff error except when the values were
7070
incorrect. Incorrect values will be fixed and the version in which the fix
7171
was made will be noted in the relevant docstring. Extension of existing
@@ -78,15 +78,15 @@ seed : {None, int, array_like}, optional
7878
Random seed initializing the pseudo-random number generator.
7979
Can be an integer, an array (or other sequence) of integers of
8080
any length, or ``None`` (the default).
81-
If `seed` is ``None``, then `RandomState` will try to read data from
81+
If `seed` is ``None``, then ``RandomState`` will try to read data from
8282
``/dev/urandom`` (or the Windows analogue) if available or seed from
8383
the clock otherwise.
8484
8585
Notes
8686
-----
8787
The Python stdlib module "random" also contains a Mersenne Twister
8888
pseudo-random number generator with a number of methods that are similar
89-
to the ones available in `RandomState`. `RandomState`, besides being
89+
to the ones available in ``RandomState``. ``RandomState``, besides being
9090
NumPy-aware, has the advantage that it provides a much larger number
9191
of probability distributions to choose from.
9292
"""

randomstate/shims/xorshift1024/xorshift1024.pxi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ generator [1]_. xorshift1024* has a period of 2**1024 - 1 and supports jumping
5858
the sequence in increments of 2**512, which allow multiple non-overlapping
5959
sequences to be generated.
6060
61-
`xorshift1024.RandomState` exposes a number of methods for generating random
61+
``xorshift1024.RandomState`` exposes a number of methods for generating random
6262
numbers drawn from a variety of probability distributions. In addition to the
6363
distribution-specific arguments, each method takes a keyword argument
6464
`size` that defaults to ``None``. If `size` is ``None``, then a single
@@ -67,10 +67,10 @@ array filled with generated values is returned. If `size` is a tuple,
6767
then an array with that shape is filled and returned.
6868
6969
*No Compatibility Guarantee*
70-
'xorshift1024.RandomState' does not make a guarantee that a fixed seed and a
71-
fixed series of calls to 'xorshift1024.RandomState' methods using the same
70+
``xorshift1024.RandomState`` does not make a guarantee that a fixed seed and a
71+
fixed series of calls to ``xorshift1024.RandomState`` methods using the same
7272
parameters will always produce the same results. This is different from
73-
'numpy.random.RandomState' guarantee. This is done to simplify improving
73+
``numpy.random.RandomState`` guarantee. This is done to simplify improving
7474
random number generators. To ensure identical results, you must use the
7575
same release version.
7676
@@ -79,7 +79,7 @@ Parameters
7979
seed : {None, int}, optional
8080
Random seed initializing the pseudo-random number generator.
8181
Can be an integer or ``None`` (the default).
82-
If `seed` is ``None``, then `xorshift1024.RandomState` will try to read data
82+
If `seed` is ``None``, then ``xorshift1024.RandomState`` will try to read data
8383
from ``/dev/urandom`` (or the Windows analogue) if available or seed from
8484
the clock otherwise.
8585

0 commit comments

Comments
 (0)