# qrandomnorm

0th

Percentile

##### Normal distributed sample of true random numbers

qrandomnorm generates normal distributed true random numbers in real-time by measuring the quantum fluctuations of the vacuum. Per default, the data follows a standard normal distribution $N(0,1)$, with mean zero and standard deviation one.

##### Usage
qrandomnorm(n = 1, mean = 0, sd = 1, method = "inverse")
##### Arguments
n

The amount of random numbers to return. Must be between 1 and 100,000.

mean

The mean-value for the normal distribution.

sd

The standard deviation for the normal distribution.

method

The method used for transforming internally used standard uniformly distributed data into normal distributed data. Currently provided methods are 'inverse' for inverse transform sampling using stats::qnorm(), 'polar' for the polar-method by George Marsaglia and 'boxmuller' for the Box-Muller transformation by George Box and Mervin Muller.

##### Details

qrandomnorm is based on the function qrandom to generate a sequence of a minimum of 1 and a maximum of 100,000 true random numbers. The true random numbers are generated in real-time by measuring the quantum fluctuations of the vacuum. The official QRNG@ANU JSON API currently supports only a maximum of 1,024 random numbers per request, thus requests for more numbers have to split up into smaller requests of maximum 1,024 numbers. In fact, each request may take a couple of seconds to be served. The greatest possible requests qrandomnorm(n = 100000, method = "polar") or qrandomnorm(n = 100000, method = "boxmuller") take about 8 minutes (via DSL 16,000 internet connection) and their size is about 781.3 KB. Per default, the sequence of numbers is transformed into a standard normal distribution $N(0,1)$, with $mean=0$ and standard deviation $sd=1$.

Internally, uniformly distributed true random numbers within the interval [0; 1] from the function qrandomunif are used to obtain normal distributed data. 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 $U(0,1)$ into a normal distribution $N(mean, sd)$:

• inverseThe sample of standard uniformly data is interpreted as a probability and transformed into a normal distribution applying the stats::qnorm() function.

• polarUsing the polar-method by George Marsaglia for generating normal distributed data.

• boxmullerUsing the Box-Muller transformation by George Box and Mervin Muller for generating normal distributed data.

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 qnorm:

 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

*non-infinite values.

At the moment, there is no limitation for the number of requests per user but if you need a huge amount of (non-live) true random numbers, there is a 10 MB, a 100 MB, a 1,000 MB and a few 5,000 MB torrents of random binary files provided for download by the ANU Quantum Random Number Generator Server here.

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.

Further information can be obtained from the ANU Quantum Random Number Generator FAQ and the list of references to scientific papers.

##### Value

qrandomnorm returns an object of class "numeric" with type "double".

The returning value of "qrandomnorm" is a "vector" containing true random numbers which are normally distributed $N(mean, sd)$.

##### References

Benjamin, April 25th, 2017, answer on teo93, "generate N(0,1) using uniform(0,1) in R", Stack Overflow, January 4th 2009, https://stackoverflow.com/a/43619239/8512077.

Box, G. E. P. and Muller, Mervin E. (1958). A Note on the Generation of Random Normal Deviates. The Annals of Mathematical Statistics, 29, No. 2, p. 610-<U+2013>611, 10.1214/aoms/1177706645.

Marsaglia, G. and Bray, T. A. (1964): A Convenient Method for Generating Normal Variables. SIAM Review, 6, No. 3, p. 260-<U+2013>264, 10.1137/1006063.

Secure Quantum Communication group, Centre for Quantum Computing and Communication Technology, Department of Quantum Sciences, Research School of Physics and Engineering, The Australian National University, Canberra, ACT 0200, Australia. Welcome to the ANU Quantum Random Numbers Server. https://qrng.anu.edu.au/index.php

Wikipedia contributors. (2018, November 2). Inverse transform sampling. In Wikipedia, The Free Encyclopedia. Retrieved 13:03, January 4, 2019, from https://en.wikipedia.org/w/index.php?title=Inverse_transform_sampling&oldid=866923287.

Wikipedia contributors. (2018, December 15). Box<U+2013>Muller transform. In Wikipedia, The Free Encyclopedia. Retrieved 12:55, January 4, 2019, from https://en.wikipedia.org/w/index.php?title=Box-3Muller_transform&oldid=873905617.

Wikipedia contributors. (2018, November 29). Marsaglia polar method. In Wikipedia, The Free Encyclopedia. Retrieved 12:57, January 4, 2019, from https://en.wikipedia.org/w/index.php?title=Marsaglia_polar_method&oldid=871161902.

qrandomunif

• qrandomnorm
##### Examples
# NOT RUN {
## request for 10 true standard normal distributed random numbers
randomNumbers <- qrandomnorm(n = 10)

## request for 10 true random numbers with mean 5 and standard deviation of 3
randomNumbers <- qrandomnorm(n = 10, mean = 5, sd = 3)

## request for 10 true random numbers with mean 8, standard deviation of 2 and using
## the polar-method by George Marsaglia to transform internally used uniformly data
## into a normal distribution
randomNumbers <- qrandomnorm(n = 10, mean = 8, sd = 2, method = "polar")

## calculate mean of randomNumbers
mean(randomNumbers)
# }
Documentation reproduced from package qrandom, version 1.0, License: GPL-2 | file LICENSE

### Community examples

Looks like there are no examples yet.