New in release 2.0
Version 2.0 of PyRandLib implements additional other "recent" PRNGs - see them listed below. It also provides two test scripts, enhanced documentation and some other internal development features. Finally, it is splitted in many subdirectories each dedicated to a specific version of Python: Python3.6, Python3.9, Python3.10, etc. In each of these directories, library PyRandLib code is fully copied and modified to take benefit of the improvements on new Python versions syntax and features. Copy the one version of value for your application to get all PyRandLib stuff at its best for your needs.
Major 2.0 novelties are listed below:
-
The WELL algorithm (Well-Equilibrated Long-period Linear, see [6], 2006) is now implemented in PyRandLib. This algorithm has proven to very quickly escape from the zeroland (up to 1,000 times faster than the Mersenne-Twister algorithm, for instance) while providing large to very large periods and rather small computation time.
In PyRandLib, the WELL algorithm is provided in next forms: Well512a, Well1024a, Well19937c and Well44497b - they all generate output values coded on 32-bits. -
The PCG algorithm (Permuted Congruential Generator, see [7], 2014) is now implemented in PyRandLib. This algorithm is a very fast and enhanced on randomness quality version of Linear Congruential Generators. It is based on solid Mathematics foundation and is clearly explained in technical report [7]. It offers jumping ahead, a hard to discover its internal state characteristic, and multi-streams feature. It passes all crush and big crush tests of TestU01.
PyRandLib implements its 3 major versions with resp. 2^32, 2^64 and 2^128 periodicities: Pcg64_32, Pcg128_64 and Pcg1024_32 classes which generate output values coded on resp. 32-, 64- and 32- bits. The original library (C and C++) can be downloaded here: https://www.pcg-random.org/downloads/pcg-cpp-0.98.zip as well as can its code be cloned from here: https://github.com/imneme/pcg-cpp. -
The CWG algorithm (Collatz-Weyl Generator, see [8], 2024) is now implemented in PyRandLib. This algorithm is fast, uses four integers as its internal state and generates chaos via multiplication and xored-shifted instructions. Periods are medium to large and the generated randomness is of up quality. It does not offer jump ahead but multi-streams feature is available via the simple modification of a well specified integer of its four integers state.
In PyRandLib, the CWG algorithm is provided in next forms: Cwg64, Cwg64-128 and Cwg128 that generate output values coded on resp. 64-, 64- and 128- bits . -
The Squares algorithm (see "Squares: A Fast Counter-Based RNG" [9], 2022) is now implemented in PyRandLib. This algorithm is fast, uses two 64-bits integers as its internal state (a counter and a key), gets a period of 2^64 and runs through 4 to 5 rounds of squaring, exchanging high and low bits and xoring intermediate values. Multi-streams feature is available via the value of the key.
In PyRandLib, the Squares32 and Squares64 versions of the algorithm are implemented. They provide resp. 32- and 64- bits output values. Caution: the 64-bits versions should not pass the birthday test, which is a randmoness issue, while this is not mentionned in the original paper [9]. -
The xoroshiro algorithm ("Scrambled Linear Pseudorandom Number Generators", see [10], 2018) is now implemented in PyRandLib, in its mult-mult form for the output scrambler. This algorithm is fast, uses 64-bits integers as its internal state and outputs 64-bits values. It uses few memory space (4, 8 or 16 64-bits integers for resp. its 256-, 512- and 1024- versions that are implemented in PyRandLib. Notice: the 256 version of the algorithm is know to show close repeats flaws, with a bad Hamming weight near zero. xoroshiro512 seems to best fit this property, according to the tables proposed by the authors in [10].
-
The MELG algorithm ("Maximally Equidistributed Long-period Linear Generators", see [11], 2018) is now implemented in PyRandLib. It can be considered as an extension of the WELL algorithm, with a maximization of the equidistribution of generated values, making computations on 64-bits integers and outputing 64-bits values.
PyRandLib implements its versions numbered 627-64, 19937-64 and 44497-64 related to the power of 2 of their periods: Melg627, Melg19937 and Melg44497. -
The SplitMix algorithm is now implemented in PyRandLib. It is used to initialize the internal state of all other PRNGs. It SHOULD NOT be used as a PRNG due to its random properties poorness.
-
Method
bytesrand()
has been added to the Python built-in classrandom.Random
since Python 3.9. So, it is also available in PyRandLib for all its Python versions: in Python 3.6 its implementation has been added into base classBaseRandom
. -
Method
random.binomialvariate()
has been added to the Python built-in classrandom.Random
since Python 3.12. So, it is also available in PyRandLib for all its Python versions: in Python -3.6, -3.9, -3.10 and -3.11 its implementation has been added into base classBaseRandom
. -
Since Python 3.12, a default value has been specified (i.e. = 1.0) for parameter
lambd
in methodrandom.Random.expovariate()
. So, it is also specified now in PyRandLib for all its Python versions: in Python -3.6, -3.9, -3.10 and -3.11 its definition has been added into base classBaseRandom
. -
A short script
testED.py
is now avalibale at root directory. It checks the equidistribution of every PRNG implemented in PyRandLib in a simple way and is used to test for their maybe bad implementation within the library. Since release 2.0 this test is run on all PRNGs.
It is now highly recommended to not use previous releases of PyRandLib (aka. 1.x). -
Another short script
testCPUPerfs.py
is now avaliable for testing CPU performance of the different implemented algorithms. It has been used to enhance this documentation by providing a new CPU Evaluations table. -
Documentation has been enhanced, with typos and erroneous docstrings fixed also.
-
All developments are now done under a newly created branch named
dev
(GitHub). This development branch may be derived into sub-branches for the development of new features. Merges fromdev
to branchmain
should only happen when creating new releases.
So, if you want to see what is currently going on for next release of PyRandLib, just check-out branchdev
. -
A Github project dedicated to PyRandLib has been created: the pyrandlib project.