A recipe for an unpredictable random number generator

In this work we present a model for computation of random processes in digital computers which solves the problem of periodic sequences and hidden errors produced by correlations. We show that systems with non-invertible non-linearities can produce unpredictable sequences of independent random numbers. We illustrate our result with some numerical calculations related with random walks simulations.

because they deviate from randomness [2,4,5,7]. It is trivial that any periodic process is not unpredictable. Suppose m T is the period of the generated sequence. Given any string of m T values: X s , X s+1 , ..., X m T −1 ; the next value X m T is always known, because the process is periodic. On the other hand, for any generator of type X n+1 = f (X n , X n−1 , . . . , X n−r+1 ), given any string of r values: X s , X s+1 , ..., X s+r−1 ; the next value X s+r is always determined by the previous r values. Thus it is not unpredictable. So the subsequences must be correlated.
An example of this can be found in Ref. [5], where the authors have shown that using common pseudo random number generators, the produced random walks present symmetries, meaning that the generated numbers are not independent. On the other hand, the logarithmic plot of the mean distance < d > versus the number of steps N is not a straight line (as expected theoretically, < d >∼ N 1/2 ) after N > 10 5 (in fact, it is a rapidly decaying function). Here d is defined as the end to end mean-square distance from the origin of the random walk as a function of the number of steps. Other papers on the influence of the pseudorandom number generator on random walk simulations are the following [11,12,13] In the following, we will show that using non-invertible nonlinear functions, we can create an unpredictable random number generator which does not contain visible correlations while simulating a random walk with the length 10 9 .
Let us investigate the following function [8,9,10]: where P (t) is a periodic function, θ is a real number, T is the period of the function P (t), and Z is a noninteger real number.
Let Z be a rational number expressed as Z = p/q, where p and q are relative prime numbers. Now let us define the following family of sequences where k, m and s are non-negative integers. The parameter k distinguishes the different sequences. For all sequences parametrized by k, the strings of m + 1 values X s , X s+1 , X s+2 , ..., X s+m are the same. This is so because , is also undetermined from the values of the string X s , X s+1 , X s+2 , ..., X s+m . There can be p different possible values. In the case of a generic irrational Z, there are infinite possibilities for the future and the past. From the observation of the string X s , X s+1 , X s+2 , ..., X s+m , there is no method for determining the next and the previous values of the sequence.
But this is not the only feature of these functions. It can be demonstrated that there are no statistical correlations between X m and X n if m = n, and that they are also independent in the sense that their probability densities satisfy the relationship P (X n , X m ) = P (X n )P (X m ) [14,15].
Moreover, we will show that, given the function (1), any string of sequences X s , X s+1 , . . . , X s+r constitutes a set of statistically independent random variables.
Without loss of generality, we assume that P (t) has zero mean and can be expressed using the following Fourier representation P (t) = ∞ k=−∞ a k e iπkt . We can calculate the r-order correlation functions [14,15]: where the coefficients k i can be different integers, and δ(n, m) When all n i are even, the following equation is satisfied The main problem in this equation occurs when one of the numbers n i is odd. In this case, the correlations E(X n 1 s X n 2 s+1 · · · X nr s+r ) must be zero. A nonzero correlation in Eq.(4) exists only for the sets (n 1 , n 2 , . . . , n r ) that satisfy the equation k 1 Z n 1 + · · · + k r Z nr = 0.
For a typical real number Z, this equation is never satisfied.
If we use non-invertible nonlinear functions, type of (1), we can implement a Truly Random Number Generator (TRNG). In this case, we propose the following function Function (5) is an example of the general case X n = P [θT Z n ] studied in this paper.
We have shown that the subsequences X s , X s+1 , . . . , X s+r constitutes a set of statistically independent random variables. The particular case of function (5) is well-known to produce uniformly distributed numbers [8,9,10].
Now we will formulate a central limit theorem. Using theorems proved in previous studies [14,15,16,17,18,19] and the results obtained from this paper, we obtain the following formula: If Z is a generic real number and X n = 2(Y n − 1/2), Y n = [θZ n ]mod1, then The Gaussian distribution of the sums is correct even for other functions X n = P [θZ n ], where P (t) is periodic. This has been shown in numerical simulations [14].
It is interesting to check the theoretical predictions using numerical simulations of the behavior of different stochastic processes.
For instance, let us study the function All the moments and higher-order correlations can be calculated exactly [14,15]: For odd m: If any n i is odd, then E(U n 0 s U n 1 s+1 · · · U nr s+r ) = 0 Suppose now that all n i are even: E(U n 0 s U n 1 s+1 · · · U nr s+r ) = 2 −(n 0 +n 1 +···+nr) Note that the condition for independence is satisfied for all integer n 0 , n 1 , . . . n r .
We have performed extensive numerical simulations that confirm the values of these moments and the independent conditions. An additional checking is the following.
The probability density of U n is ρ(U) = 1 π √ 1−U 2 . Define V n = U n+1 . The probability density of V n is ρ(V ) = 1 π √ 1−V 2 . We have checked both theoretically and numerically that , that is ρ(U, V ) = ρ(U)ρ(V ). This can be observed in Fig. 1 and   Fig. 2. In order to avoid computation problems, we have used the following procedure. We where C s is a sequence obtained using the digits of the Champernowne's number [20]  Using this method we have generated a very long sequence of random numbers without computational problems.
To test function (5) as a truly random number generator, we have implemented a random walk simulation program in C++. We have made a sampling test of a random walk with N = 10 9 steps with 100 realizations with different initial seeds. The mean distance d was calculated every 1000 steps of the random walk.
The Champernowne sequence of numbers used in the generator was produced previously by a short C++ program, who created a sequence of a maximum of 40000 Champernowne's numbers. If a larger amount of values to C s is necessary, it can be obtained using a segment code that uses the 40 thousand values already stored in C s and mixing them, e.g the algo-rithm takes the first value of the series C 1 , the third C 3 and so on, and adds them at the end of the series, obtaining that C s+1 = C 1 , C s+2 = C 3 ,...; if more values are necessary, this procedure or cycle is repeated but now skipping two values C 1 , C 3 , C 5 ,... three values C 1 , C 4 , C 7 and so on. In this way, we can make the C s sequence as large as we wish.
We present a logarithmic plot of the mean distance < d > versus the number of steps N with N = 10 9 steps with A = 6.9109366 and Z = π/2 (See Fig. 3). We can verify that there is no deviation from the theoretical straight line, even for N >> 10 5 steps, which is a very good test of the reliability of the Random Number Generator used in the random walk simulations. a) for generator (5), b) the same simulation for a generator of type X n+1 = aX n mod T .
We have presented a random number generator based on the properties of non-invertible transformations of truncated exponential functions. The obtained random process is unpredictable in the sense that the next values are not determined by the previous values. We have applied this generator to the numerical simulation of statistically independent random variables. In the simulation of a random walk with the length 10 9 , the random process does not contain visible correlations.