Quantum random numbers
Project description
Quantum random numbers in Python
This package brings the ANU quantum random numbers to Python 3.6+.
The default pseudo-random generator in Python is replaced by calls to the ANU API that serves real quantum random numbers.
pip install quantum-random
Just import qrandom
and use it like you'd use the
standard Python random module. For example,
>>> import qrandom
>>> qrandom.random()
0.15357449726583722
>>> qrandom.sample(range(10), 2)
[6, 4]
>>> qrandom.gauss(0.0, 1.0)
-0.8370871276247828
The qrandom
module exposes a class (QuantumRandom
) derived from
random.Random
with a random()
method that outputs quantum floats in the
range [0, 1) (converted from 64-bit ints). Overriding random.Random.random
is sufficient to make the qrandom
module behave like the random
module as
described in the Python docs. Batches of quantum numbers are
fetched from the API as needed and each batch contains 1024 numbers. If you
wish to pre-fetch more, use qrandom.fill(n)
, where n
is the number of
batches.
To run the tests locally, you will need poetry and Python 3.6-3.9.
poetry install
poetry run tox
See here for a visualisation and a Kolmogorov–Smirnov test.
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
Hashes for quantum_random-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d564352264970e86d05078bc2c1dbd487199a2315f37c788187cd5350458914 |
|
MD5 | c6697f80f6b58a99f77c869be817cbad |
|
BLAKE2b-256 | 4d1959357707f60941dec9694f10f134c6e2f4b34e1cd983b6596ba47b6d9e8b |