Random generator supporting multiple PRNGs
Actively maintained. Last release 4 weeks ago, commits in 17 of the last 26 weeks. A safe choice.
pip install randomgenREADME as published on PyPI with version 2.5.1.
Random generator supporting multiple PRNGs
Actively maintained. Last release 4 weeks ago, commits in 17 of the last 26 weeks. A safe choice.
pip install randomgenREADME as published on PyPI with version 2.5.1.
This is a library and generic interface for alternative random generators in Python and NumPy.
See the development documentation for the latest features, or the stable documentation for the latest released features.
Generator and RandomState were removed in 1.23.0.
Generator and RandomState have been officially deprecated in 1.19, and will
warn with a FutureWarning about their removal. They will also receive virtually
no maintenance. It is now time to move to NumPy's np.random.Generator which has
features not in randomstate.Generator and is maintained more actively.
A few distributions that are not present in np.random.Generator have been moved
to randomstate.ExtendedGenerator:
multivariate_normal: which supports broadcastinguintegers: fast 32 and 64-bit uniform integerscomplex_normal: scalar complex normalsThere are no plans to remove any of the bit generators, e.g., AESCounter,
ThreeFry, or PCG64.
There are many changes between v1.16.x and v1.18.x. These reflect API
decision taken in conjunction with NumPy in preparation of the core
of randomgen being used as the preferred random number generator in
NumPy. These all issue DeprecationWarnings except for BasicRNG.generator
which raises NotImplementedError. The C-API has also changed to reflect
the preferred naming the underlying Pseudo-RNGs, which are now known as
bit generators (or BitGenerators).
This module includes a number of alternative random number generators in addition to the MT19937 that is included in NumPy. The RNGs include:
AESCounter, SPECK128, ChaCha, and HC128.RDRAND.SFC64) and Jenkin's Small-Fast (JSF).The package version matches the latest version of NumPy when the package is released.
Documentation for the latest release is available on my GitHub pages. Documentation for the latest commit (unreleased) is available under devel.
Building requires:
Testing requires pytest (9+).
The development dependencies are dependency groups in pyproject.toml.
With pip 25.1 or later, install everything needed to build, test and lint
randomgen, and then randomgen itself, with
python -m pip install --group dev
python -m pip install -e . --no-build-isolation
The groups are build, test, lint, doc (for the documentation) and
dev (build, test and lint together).
Note: it might work with other versions but only tested with these versions.
All development has been on 64-bit Linux, and it is regularly tested on Azure (Linux-AMD64, Windows, and macOS) and GitHub Actions (Linux-ARM64, Windows-ARM64 and free-threaded Python).
Tests are in place for all RNGs. The MT19937 is tested against NumPy's implementation for identical results. It also passes NumPy's test suite where still relevant.
Either install from PyPi using
python -m pip install randomgen
or, if you want the latest version,
python -m pip install git+https://github.com/bashtage/randomgen.git
or from a cloned repo,
python -m pip install .
If you use conda, you can install using conda forge
conda install -c conda-forge randomgen
dSFMT and SFMT make use of SSE2 by default. If you have a very old
computer or are building on non-x86, you can install using:
python -m pip install . -Csetup-args=-Ddisable-sse2=true
Either use a binary wheel, or if building from scratch, use the Visual Studio
Build Tools (MSVC). Builds with clang-cl are also tested.
Dual: BSD 3-Clause and NCSA, plus sub licenses for components.