randomity is a comprehensive statistical suite and Python library designed to measure the unpredictability of pseudo-random number generators (PRNGs) and true random number generators (TRNGs). The package provides tools to generate sequences using industry-standard algorithms, implement quantum-generated randomness via Qiskit, and evaluate those sequences across multiple statistical dimensions to compute a composite randomness score.
The project implements several generation strategies, including Linear Congruential Generators (LCG), Mersenne Twister, XORShift, Blum Blum Shub, and Middle Square algorithms, alongside a Quantum Random Number Generator (QRNG) that leverages single-qubit measurement collapse.
Approach
The core of the package is a multi-dimensional evaluation engine that categorizes randomness into three primary paradigms: Uniformity, Patterns, and Periodicity. Each paradigm was evaluated using a suite of statistical tests. To provide a clear assessment, randomity implements a normalization pipeline that maps disparate statistical metrics (such as p-values and spectral magnitudes) onto a standardized [0,1] scale. These normalized values are then synthesized into a composite Randomness Score, allowing for a direct, comparative evaluation of different generators.
Usage
To install and use randomity:
pip install randomity
Evaluating a Sequence
You can use the isRandom function to determine if a sequence meets a specific unpredictability threshold (default is 0.6):
from randomity.evaluate import isRandom
# A sample sequence of numbers
my_sequence = [7, 1, 0, 4, 1, 9, 3, 2, 8, 5]
# Returns a boolean based on the composite score
result = isRandom(my_sequence, threshold=0.6)
print(f"Is it random? {result}")
Generating Random Sequences
The package provides dedicated modules for both pseudo and quantum generation:
from randomity.generate import pseudo, quantum
# Generate a sequence using the Mersenne Twister algorithm
prng_seq = pseudo.mersenne_twister(n=1000)
# Generate a sequence using a Quantum Random Number Generator (requires qiskit)
qrng_seq = quantum.qrng(n=100)
Inspection
For a deeper look into why a sequence passed or failed, you can inspect the individual scores for each paradigm:
from randomity.evaluate import inspectRandom
# Get a dictionary of sub-scores for Uniformity, Patterns, and Periodicity
report = inspectRandom(my_sequence)
print(report)
Contributing
To contribute to this project, you can fork this repository and create pull requests. You can also open an issue if you find a bug or wish to make a suggestion.
License
This project is licensed under the GNU General Public License (GPL).
Metadata
Release files for randomity 0.5.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| randomity-0.5.7.tar.gz | 640.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| randomity-0.5.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 672.8 kB
Release files / randomity-0.5.7.tar.gz
| Download URL | randomity-0.5.7.tar.gz |
|---|---|
| Size | 640.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03ca794a20452e0c60812ac96708105f83c4c05868fb0142bce005d2b61aa3c6
|
|
BLAKE2b-256 checksum How to use checksums |
b2be8a547eb3e1220da3ed4eb3f5f57c8896935f8147d9d59cd2fceb8129dd13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.14
|
Release files / randomity-0.5.7-py3-none-any.whl
| Download URL | randomity-0.5.7-py3-none-any.whl |
|---|---|
| Size | 32.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f216055bfceb017dfc32f009c2667163d7cd517a2fa65a87f99ca7401eea96f
|
|
BLAKE2b-256 checksum How to use checksums |
c01fb5f3520ac5e3d3177fbe7267bf9d4e96ad0b96e0b325b7d1136e2b3aace1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.14
|
Security for randomity 0.5.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.