A package for generating and assessing randomness.
Project description
randomity
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).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file randomity-0.5.6.tar.gz.
File metadata
- Download URL: randomity-0.5.6.tar.gz
- Upload date:
- Size: 640.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79c7e3ac91ef67858d522e45200db9629882a8619d69d539fd22add174cb146b
|
|
| MD5 |
f05e3587c5feeee4604860882fa64805
|
|
| BLAKE2b-256 |
ea42edcbbb70864254c83ed4231e4a751fdada3e48dea713775b934b77eae803
|
File details
Details for the file randomity-0.5.6-py3-none-any.whl.
File metadata
- Download URL: randomity-0.5.6-py3-none-any.whl
- Upload date:
- Size: 32.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa5c5bd06483fd4665259d86cc866246563e2620f665f7212be8419f782e0db
|
|
| MD5 |
64b1447d1fcf4763c981624fe868d668
|
|
| BLAKE2b-256 |
6c9d2847a2a23930e770a383d644de6e0cedbc19bf03b8d9240ad959e0d7f55b
|