Extending RandomState to handle multiple generators
See original GitHub issueI have been working on a more general implementation of RandomState that allow multiple RNGs to be implemented. The repo is here
Currently it passes the NumPy test suite for mt19937 as well as another direct comparrison.
The library consists of a few layers:
- The source for the RNG
- A shim library that provides a few core RNGs - uint 32/64 and double
- A shared set of C/pyx code that use definitions and Cython conditional compilation
Ultimately this will generate libraries for any include random number where each library contains the same RandomState class that is in Numpy. Currently the following RNGs are available (on Linux and other unix-like OSes + Windows Py 3.5)
- mt19937 (identical to the NumPy implementation)
- xorshift128+ and xorshift1024*
- pcg-32 and pcg-64
- mrg32k3a (popular but slow, not sure it should be included in any final version)
- A basic MLFG
It is pretty easy to add new core RNGs.
In addition, it supports jump
and advance
for RNGs that have these capabilities, which makes it suitable for use in parallel applications.
Still has a way to go, especially for Windows 2.7/3.4 support, but seems close enough to start talking about and getting feedback.
xref #2039
Issue Analytics
- State:
- Created 8 years ago
- Reactions:9
- Comments:16 (12 by maintainers)
Top GitHub Comments
xref #13163 . This is fixed in the randomgen branch.
@bashtage This is kind of a dumb question, but could you please clarify for me the difference between jumping and advancing an RNG?