Releases: schmouk/PyRandLib
v2.1.0 Release - 2025/07
New in Release 2.1
Version 2.1 of PyRandLib is now fully unit-tested. The code coverage is 100%. Test code is available in subdirectory unit-tests
of every Python version directory.
A few bugs have then been fixed:
- protected method
Pcg1024_32._externalstep()
implementation is now correct; - a typo in a shifting constant in Well19937c
.next()
has been fixed (erroneous value19
has been fixed to correct value9
).
Notice: Release 2.0 of PyRandLib is nevertheless still available but it should no more be used.
v2.0.0 Release - 2025/03
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.
v1.2.3 Release - 2022/09
Just modified copyright dates and author e-mail address where appropriate.
This is concomitant with the delivery of release v1.0.0 of CppRandLib, the c++ version of PyRandLib.
v1.2.2 Release - 2021/08
Fixed a few typos and corrected document README.md
.
All the other enhancements issued from v1.2.0 are:
- Implemented new signature for method
__call__()
- i.e. operator()
, in classBaseRandom
. See fileREADME.md
for its new usage which is still backward compatible with former versions of the library; - Optimized the initialization of internal states when they are lists;
- Uses now underscores in numerical constants (as introduced in Python 3.6) to enhance the readability of the code;
- Fixed a same small bug in methods
.setState()
of both base classesBaseLFib64
andBaseMRG
; - Renamed mispelled type
Numeric
, replaced byNumerical
; - modified file
README.md
accordingly;
v1.2.0 Release - 2021/08
- Implemented new signature for method
__call__()
- i.e. operator()
, in classBaseRandom
. See fileREADME.md
for its new usage which is still backward compatible with former versions of the library; - Optimized the initialization of internal states when they are lists;
- Uses now underscores in numerical constants (as introduced in Python 3.6) to enhance the readability of the code;
- Fixed a same small bug in methods
.setState()
of both base classesBaseLFib64
andBaseMRG
; - Renamed mispelled type
Numeric
, replaced byNumerical
; - modified file
README.md
accordingly;
v1.1.0 Release - 2021/01
- Modified copyright dates to 2021;
- added back Unix and UTF-8 goodies at top of all files;
- conforms now to new documentation rules;
- added usage of typing for types annotations.
v1.0.6 Release - 2020/01
- Modified copyright dates;
- Python 3.8.
v1.0.5 Release
Minor release - code conforms now with Pyton PEP 484 -- Type Hints.
v1.0.4 Release
Major bug fixed in module MRG - 287.
v1.0.3.71 Release
Fixed a bug in module fastrand32.py (method setstate()
)