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 (qrandom.QuantumRandom
) derived from
random.Random
with a random
method that outputs quantum floats in the
range [0.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. A batch of 1024 quantum numbers are
fetched from the API at a time. If you wish to pre-fetch, use qrandom.fill(n)
,
where n
is the number of 1024-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.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5f8b1f81fa418a0ecbac8f548faddabc070998772652a694afa19fe41ec356e |
|
MD5 | 0fc9795321b9c1878480123975b261e5 |
|
BLAKE2b-256 | 27ec01ad24209036c9ad09d46768a8b10ab3489baa74ae01414a52f664537973 |