# Generation of pseudo-random numbers with the use of inverse chaotic transformation

Marcin Lawnik
From the journal Open Mathematics

# Abstract

In (Lawnik M., Generation of numbers with the distribution close to uniform with the use of chaotic maps, In: Obaidat M.S., Kacprzyk J., Ören T. (Ed.), International Conference on Simulation and Modeling Methodologies, Technologies and Applications (SIMULTECH) (28-30 August 2014, Vienna, Austria), SCITEPRESS, 2014) Lawnik discussed a method of generating pseudo-random numbers from uniform distribution with the use of adequate chaotic transformation. The method enables the “flattening” of continuous distributions to uniform one. In this paper a inverse process to the above-mentioned method is presented, and, in consequence, a new manner of generating pseudo-random numbers from a given continuous distribution. The method utilizes the frequency of the occurrence of successive branches of chaotic transformation in the process of “flattening”. To generate the values from the given distribution one discrete and one continuous value of a random variable are required. The presented method does not directly involve the knowledge of the density function or the cumulative distribution function, which is, undoubtedly, a great advantage in comparison with other well-known methods. The described method was analysed on the example of the standard normal distribution.

MSC 2010: 37M25; 11K45; 62E99

## 1 Introduction

The generation of pseudo-random numbers is crucial in many fields of science like cryptography, where cryptographically secure pseudo-random numbers are needed e.g. [1] or scientific computations, where often numbers from another than uniform distribution are crucial e.g. [2, 3].

There are many published algorithms that enable the derivation of values from the given probability distribution. One of the most popular is the method of inverse cumulative distribution function determined by the equation [4]:

X=F1(U),(1)

where U is a random variable from the uniform distribution on interval (0, 1), F−1 is a quantile function and X is a random variable with distribution corresponding to F.

Another very popular method for pseudo-random numbers generation is the rejection (also called acceptance and rejection) method, which is the implication of the following observation [5]:

if a random point (X, Y) is uniformly distributed in the region Gf between the graph of the density function f and the x-axis, then random variable X has density f.

Additionally, in professional literature the methods which allow the generation of pseudo random numbers from a concrete distribution can be found, for example, from the normal one [6, 7, 8, 9]. One of such algorithms is the Box-Muller transformation given by the equations [6]:

N1=2lnU1cos2πU2 and N2=2lnU1sin2πU2,(2)

where N1 and N2 are standard normal random variables, whereas U1 and U2 are random variables from uniform distribution.

Apart from these classical methods, there are also ways of constructing chaotic maps solving the so-called inverse Frobenious-Perron problem [10, 11, 12], which enables the construction of recurrences with predefined invariant densities. Iterating such dynamical systems is an easy way of generating pseudo-random numbers. One of such recurrences is in the following form [13]:

xk+1=F1UF(xk),(3)

where F is a given cumulative distribution function, F−1 is the inverse function to F and U is the skew tent map. The skew tent map (also called as the asymmetric tent map) is given by the relation:

xk+1=f(xk)=xkp0<xkp1xk1pp<xk<1.(4)

For each value of parameter p ∈ (0, 1), the recurrence (4) is chaotic and has a uniform distribution of the iterated variable. Due to these properties, reccurence (4) is very popular as a component of pseudorandom number generators in cryptographic applications [14, 15, 16].

Transformations in the form of (3) were analyzed in [17]. The derived results indicate that for values of parameter p close to 0 or 1, the desired probability distribution of the iterative variable cannot be derived. The reason is a small -– close to zero – value of the Lyapunov exponent, which measures the rates of convergence or divergence of nearby trajectories. The Lyapunov exponent of the dynamical system xk+1 = f(xk) is given by the formula:

λ=limm1mi=0m1ln|f(xi)|.(5)

Furthermore, methods for generating pseudo-random numbers with the use of chaotic maps related only to a specific distribution can be shown, for example the normal distribution with the use of the Weierstrass recurrence, which was firstly shown in [18] and futher analized in [19]. The Weierstrass recurrence can be expressed by the formula:

xk+1=i=0Naicos(biπxk),(6)

where 0 < a < 1, b is a odd number and ab>1+32π. As shown in [19], iterating (6) with parameter value a close to 1, generates values from the normal distribution.

Another method which applies chaotic maps in pseudo-random numbers generation was shown in [20], where values from uniform distribution are generated. This method may be described by the following procedure:

## Method 1

LetUn (x) denote the n-th iteration of the chaotic map with a uniform distribution starting from initial condition x. Furthermore, let:

X={x0,x1,,xN1}(7)

be a certain pseudo-random set of numbers from continuous distribution with finite support. In such case, the set

U={u0=Un|ax0|,u1=Un|ax1|,,uN1=Un|axN1|}(8)

where a is a normative coefficient, has the distribution similar to uniform.

The above procedure enables the ”flattening” of continous distribution, i.e. reducing it to the uniform distribution. Furthermore, the accuracy of this process depends on the number of iterations n - if it is too small, then the obtained distribution only ”flattens” the oryginal density functions of (7). The transformation f may be chosen as the skew tent map (4). Other examples of chaotic maps with uniform distribution may be found in [21, 22]. Likewise, as recurrence (4), they consist of several independent functions, which may be called as branches.

While analyzing the above-described method a natural question arises: Is the process of reduction of any distribution to the uniform distribution reversible? If yes, then in consequence, a new method enabling the generation of pseudo-random numbers from any distribution could be derived. The fact that the transformation described in (8) is a 1D chaotic map means that it is irreversible. However, by additional assumptions the process may become reversible, which is discussed in the next section of this paper.

## 2 Method and analysis

The inversion of a chaotic transformation given, for example, by (4) does not render an unequivocal solution. Yet, knowing which of the branches of the transformation were iterated, the chaotic map may be inverted. This may be achieved by finding successive inverse images by means of a inverse function to an appropriate branch. Assuming that we have two branches that are denoted as ”0” and ”1” (see Fig. 1), any orbit starting from an initial point in (7) creates a certain binary sequence. Thus, by replacing every binary sequence with the appropriate integer number, in consequence, a set of integers is derived. Next, for such set it is possible to calculate the frequency of the occurrence wi of particular integers, in accordance with the dependence:

wi=niN,(9)

where ni denotes the amount of successive integers in the above-mentioned set and i = 0,1,…,2n − 1.

### Fig. 1

Skew tent map (4) with the assignment of the values of 0 and 1 to successive branches.

An example of such numerical normalized frequency set is shown in Fig. 2. Conducted numerical analysis has shown, that this set is invariant if the number of elements in (7) changes and the values of parameters p, a and n are fixed. Changing values in the mentioned parameters provides a new set of elements in the form (9).

### Fig. 2

Frequency wi of particular combinations of the branches of recurrence (4) with n = 7 and p = 0.45.

Thus, the algorithm of generating pseudo-random numbers from the given distribution with the use of transformation f may be described by the following procedure:

1. Set the values of the frequency of the occurrence wi.

2. In accordance with wi, generate an adequate value of discrete random variable i from the set {0,1,…,2n − 1}.

3. Generate a value of random variable u ∈ (0, 1) from the uniform distribution.

4. In accordance with i inverse the value of u by calculating x = fi(u), where f is the mapping used to get (9).

5. Return x.

Above-described algorithm is an approximate method of generation of pseudo-random numbers. It can be seen as a form of decomposition method of distributions. The accuracy of the method depends on the values of wi, which must be designated for properly large set X with adequate number of iterations n. Next, the derived values of wi may be catalogued. Then, to generate the values from the given distribution it is not necessary to know the density function or the cumulative distribution function. This eliminates the first step in above proposed algorithm. In comparison with other methods, such as inversion of the cumulative distribution function, or method of acceptance-rejection, it is, undoubtedly, a great advantage. Nevertheless, the algorithm requires to generate two values of random variables (one discrete and one from uniform distribution) which in comparison with the inversion cumulative distribution method is a disadvantage.

## 3 Example

The implementation of the above-described method shall be presented on the example of standard normal distribution. Accordingly, taking advantage of (8) and (4) the frequency of the occurrence of specific combinations of the brancheswi (9) was calculated. The results are presented in Fig. 2. Next, on the grounds of the frequencies using presented algorithm, a sequence of pseudo-random numbers was generated which numerically calculated density function shown in Fig. 3. The obtained results show good matching of the obtained distribution with the standard normal distribution. Moreover, a series of statistical tests was carried out to verify the properties of the analysed method. The results are compiled in Table 1, certifying that the discussed method enables the generation of pseudo-random numbers from standard normal distribution.

### Fig. 3

Numerically obtained density function of the set of numbers derived by means of the presented algorithm (black line), red line shows the standard normal distribution.

### Table 1

Normality tests (from scipy.stats - Python module for statistics [23]) results for 500000 computed values with presented algorithm with skew tent map (4).

TestStatistics valuep-value
p = 0.33.5324
n = 6p = 0.50.3252
p = 0.780.3513
p = 0.31.7116
Anderson-Darlingn = 7p = 0.50.7574
p = 0.78.5477
p = 0.30.5129
n = 8p = 0.50.3032
p = 0.71.2678
p = 0.32.15390.0312
n = 6p = 0.50.67700.4983
p = 0.79.88005.0827e-23
p = 0.31.07190.2837
Kurtosistestn = 7p = 0.50.25840.7960
p = 0.72.37180.0176
p = 0.30.60350.5461
n = 8p = 0.51.89360.0582
p = 0.71.37200.1700
p = 0.34.82050.0897
n = 6p = 0.51.54070.4628
p = 0.797.8085.7683e-22
p = 0.31.81720.4030
Normaltestn = 7p = 0.52.51140.2848
p = 0.75.83780.0539
p = 0.30.82440.6621
n = 8p = 0.53.62350.1633
p = 0.72.11880.3466
p = 0.3-0.42550.6704
n = 6p = 0.51.04030.2981
p = 0.70.44080.6592
p = 0.30.81740.4136
Skewtestn = 7p = 0.51.56350.1179
p = 0.70.46050.6450
p = 0.30.67830.4975
n = 8p = 0.50.19360.8464
p = 0.70.48610.6268

## 4 Conclusions

The method discussed in the paper enables the generation of pseudo-random numbers from a given distribution. It requires the knowledge of the frequency of the occurrence of particular branches of the transformation during the process of generating the uniform distribution described in [20]. However, neither the density function nor the cumulative distribution function are directly used in the method. The method was numerically analysed on the example of standard normal distribution. The obtained results prove its accuracy. It may be applied to create a series of generators of pseudo-random numbers from continuous probability distribution.

### References

[1] Blum L., Blum M., Shub M., A Simple Unpredictable Pseudo-Random Number Generator. SIAM Journal on Computing, 1986, 15 (2), 364–38310.1137/0215025Search in Google Scholar

[2] Woźniak M., Połap D., On some aspects of genetic and evolutionary methods for optimization purposes, Int. J. Electron. Telecommun, 2015, 61(1), 7–1610.1515/eletel-2015-0001Search in Google Scholar

[3] Słota D., Using genetic algorithms for the determination of an heat transfer coefficient in three-phase inverse Stefan problem, Int. Commun. Heat Mass Transf., 2008, 35(2), 149–15610.1016/j.icheatmasstransfer.2007.08.010Search in Google Scholar

[4] Devroye L., Non-Uniform Random Variate Generation, Springer, 198610.1007/978-1-4613-8643-8Search in Google Scholar

[5] Hörmann W., Leydold J., Derflinger G., Automatic Nonuniform Random Variate Generation, Springer-Verlag, Berlin Heidelberg, 200410.1007/978-3-662-05946-3Search in Google Scholar

[6] Box G.E.P., Muller M.E, A Note on the Generation of Random Normal Deviates, Ann. Math. Stat., 1958, 29(2), 610–61110.1214/aoms/1177706645Search in Google Scholar

[7] Marsaglia G., Bray T.A., A convenient method for generating normal variables, SIAM Rev., 1964, 6, 260–26410.1137/1006063Search in Google Scholar

[8] Leva J.L., A fast normal random number generator, ACM T. Math. Softw., 1992, 18, 449–45310.1145/138351.138364Search in Google Scholar

[9] Afflerbach L., Wenzel K., Algorithm Normal random numbers lying on spirals and clubs, Stat. Pap., 1998, 29, 237–24410.1007/BF02924529Search in Google Scholar

[10] Pingel D., Schmelcher P., Diakonos F.K., Theory and examples of the inverse Frobenius–Perron problem for complete chaotic maps, Chaos, 1999, 9(2), 357–36610.1063/1.166413Search in Google Scholar

[11] Koga S., The Inverse Problem of Flobenius-Perron Equations in 1D Difference Systems: 1D Map Idealization, Prog. Theory. Phys., 1991, 86(5), 991–100210.1143/ptp/86.5.991Search in Google Scholar

[12] Grossmann S., Thomae S., Invariant Distributions and Stationary Correlation Functions of One-Dimensional Discrete Processes, Z. Naturforsch, 1977, 32, 1353–136310.1515/zna-1977-1204Search in Google Scholar

[13] Lai D., Chen G., Generating Different Statistical Distributions By The Chaotic Skew Tent Map, Int. J. Bifurcat. Chaos, 2000, 10, 1509–151210.1142/S0218127400000955Search in Google Scholar

[14] Palacios-Luengas L., Delgado-Gutiérrez G., Díaz-Méndez J.A., et al., Symmetric cryptosystem based on skew tent map, Multimed Tools Appl, 2017, 1–3210.1007/s11042-017-4375-9Search in Google Scholar

[15] Li C., Luo G., Qin K., Li C., An image encryption scheme based on chaotic tent map, Nonlinear Dynamics, 2017, 87(1), 127–13310.1007/s11071-016-3030-8Search in Google Scholar

[16] Khan J., Ahmad J., Hwang S.O., An efficient image encryption scheme based on: Henon map, skew tent map and S-Box, In: 6th International Conference on Modeling, Simulation, and Applied Optimization (ICMSAO) (27-29 May 2015 Istanbul, Turkey), 2015, 1–610.1109/ICMSAO.2015.7152261Search in Google Scholar

[17] Lawnik M., Analysis of the chaotic maps generating different statistical distributions, J. Phys.: Conf. Ser., 2015, 633(012086), 1–410.1088/1742-6596/633/1/012086Search in Google Scholar

[18] Berezowski M., Lawnik M., Identification of fast-changing signals by means of adaptive chaotic transformations, Nonlinear Anal. Model. Control, 2014, 19(2), 172–17710.15388/NA.2014.2.2Search in Google Scholar

[19] Lawnik M., The approximation of the normal distribution by means of chaotic expression, J. Phys.: Conf. Ser., 2014, 490(012072), 1–410.1088/1742-6596/490/1/012072Search in Google Scholar

[20] Lawnik M., Generation of numbers with the distribution close to uniform with the use of chaotic maps, In: Obaidat M.S., Kacprzyk J., Ören T. (Ed.), International Conference on Simulation and Modeling Methodologies, Technologies and Applications (SIMULTECH) (28-30 August 2014, Vienna, Austria), SCITEPRESS, 2014, 451–45510.5220/0005090304510455Search in Google Scholar

[21] Huang W., Characterizing chaotic processes that generate uniform invariant density, Chaos, Soliton Fract., 2005, 25(2), 449–46010.1016/j.chaos.2004.11.016Search in Google Scholar

[22] Anikin V.M., Arkadaksky S.S., Kuptsov S.S., Remizov A.S., Vasilenko L.P., Lyapunov exponent for chaotic 1D maps with uniform invariant distribution, B. Russ. Aca. Sci. Phys., 2008, 72(12), 1684–168810.3103/S106287380812023XSearch in Google Scholar

[23] Python scipy.stats module, (last access 23.03.2016)Search in Google Scholar