qrandom is an R package providing an interface to the ANU Quantum Random Number Generator provided by the Australian National University. An ultra-high bandwith of true random numbers is generated in real-time by measuring the quantum fluctuations of the vacuum. The quantum Random Number Generator is based on the papers Real time demonstration of high bitrate quantum random number generation with coherent laser light by Symul et al., (2011) and
Maximization of Extractable Randomness in a Quantum Random-Number Generator by Haw, et al. (2015).
This package offers functions to retrieve a sequence of random integers, signed integers, hexadecimals, and UUID's. Furthermore, one is able to generate true random samples from a normal or uniform distribution. Functions of
- qrandom (sequence of true random numbers)
- qrandomunif (true random numbers from a uniform distribution)
- qrandomnorm (true random numbers from a normal distribution)
- qrandommaxint (true random uniformly distributed signed integers in the range
- qUUID (true random Universally Unique IDentifiers (UUID), conforming to RFC 4122)
# The easiest way to install qrandom is to download via CRAN install.packages("qrandom") # Alternatively, you can install the development version from GitHub # install.packages("devtools") devtools::install_github("skoestlmeier/qrandom")
We try our best to provide unique true random numbers. All API requests provided by this package are using SSL. As long as nobody is able to break the encryption protocol, the random numbers you obtain should be unique and secure.
The true random numbers provided by this package are generated in real-time by measuring the quantum fluctuations of the vacuum. The official QRNG@ANU API currently supports only a maximum of 1,024 random numbers per request, thus requests for more numbers have to be splitted up into smaller requests of a maximum of 1,024 numbers. In fact, each request may take a couple of seconds to be served.
The greatest possible number of requests per function
qrandom(n = 100000, type = "hex16", blocksize = 1024)takes about 13 minutes and its size is about 201.4 MB
qrandomunif(n = 100000)takes about 7 minutes and its size is about 781.3 KB
qrandomnorm(n = 100000, method = "boxmuller")takes about 8 minutes and its size is about 781.3 KB
qrandommaxint(n = 100000)takes about 4 minutes and its size is about 400.0 KB
qUUID(n = 100000)takes about 4 minutes and its size is about 9.9 MB
via a DSL 16,000 internet connection.
This function generates a true random sequence of up to 100,000 numbers per request. The type
- 'uint8' generates integer values between 0 and 255 (both including).
- 'uint16' generates integer values between 0 and 65,535 (both including).
- 'hex16' generates hexadecimal values between 00 and ff (both including).
The option 'blocksize' is only needed for request type 'hex16' and sets the length of each block which can be a length between 1 and 1,024 (both including). Further information can be obtained by the official QRNG@ANU API documentation here.
This function returns a sample of 1 - 100,000 true random numbers from a uniform distribution with parameters a (minimum value) and b (maximum value), both a and b included, i.e. all values are within the interval [a; b]. Per default (a=0 and b=1), a standard uniform distribution is assumed.
This function returns a sample of 1 - 100,000 true random numbers from a normal distribution. Per default, a standard normal distribution with mean zero and standard deviation of one is assumed.
Internally, uniformly distributed true random numbers within the interval [0; 1] are requested via
qrandomunif(). Within these uniformly data, the smallest possible number greater than zero is 2.220446e-16 and the largest possible number less than one is 0.9999999999999997779554.
We provide three methods to transform our standard uniformly data into a normal distribution:
Inverse transform sampling: The sample of standard uniformly data is interpreted as a probability and transformed into a normal distribution applying the
The polar-method by George Marsaglia.
Box-Muller transformation by George Box and Mervin Muller.
Be aware that only the default method 'inverse' is able to return -Inf and +Inf z-values for the normal distribution. The following table summarizes the non-infinite minimum and maximum z-values for a standard normal distribution for each method provided and compares them with the non-infinite extreme values from the R-core function
method stats:qnorm() inverse polar boxmuller minimum z-value* -8.209536 -8.12589 -8.36707 -8.490424 maximum z-value* 8.209536 8.12589 8.36707 8.490424 z-values +- Inf Yes Yes No No
This function returns a sample of 1 - 100,000 true random uniformly distributed signed integers in the range
This function returns true random Universally Unique IDentifiers (UUID), conforming to RFC 4122.
- Add more tests to increase codecov.
- Ziggurat algorithm for 'qrandomnorm'.
- Speed up / parallelize requests for thousands of true random numbers in 'qrandom'.
Constributions in form of feedback, comments, code, bug reports or pull requests are most welcome. How to contribute:
- Issues, bug reports, or desired expansions: File a GitHub issue.
- Fork the source code, modify it, and issue a pull request through the project GitHub page.
Please read the contribution guidelines on how to contribute to this R-package.
Code of conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
qrandom -- An R interface to the ANU Quantum Random Numbers Server
Copyright (C) 2020 Siegfried Köstlmeier firstname.lastname@example.org
qrandom is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
qrandom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
qrandom. If not, see http://www.gnu.org/licenses/.