Poisson Twister Generator by Cumulative Frequency Technology

The widely known generators of Poisson random variables are associated with different modifications of the algorithm based on the convergence in probability of a sequence of uniform random variables to the created stochastic number. However, in some situations, this approach yields different discrete Poisson probability distributions and skipping in the generated numbers. This article offers a new approach for creating Poisson random variables based on the complete twister generator of uniform random variables, using cumulative frequency technology. The simulation results confirm that probabilistic and frequency distributions of the obtained stochastic numbers completely coincide with the theoretical Poisson distribution. Moreover, combining this new approach with the tuning algorithm of basic twister generation allows for a significant increase in length of the created sequences without using additional RAM of the computer.


Introduction
Using generators of Poisson random variables realizes a stochastic process of creating integer random numbers η ∈ H having the following probability distribution with respect to the real parameter α [1,2]: where η takes any integer values such as 0, 1, 2, . . . , ∞. The Poisson model usually describes a scheme of rare events: under certain assumptions about the nature of a process with random events, the number of elements observed over a fixed time interval or in a fixed region of space is often a subject of Poisson distribution. Examples include the number of particles of radioactive decay registered by a counter for some period of time, the number of calls received to a telephone switching exchange during the designated time, the number of defects in a piece of cloth or in a tape of fixed length, etc. Thus, Poisson distribution simulates a random variable that represents the number of events that occurred over a fixed time. These events happened with some fixed average intensity and independently of each other. At the same time, Poisson distribution is discrete, which is one of the important limiting cases of a binomial distribution. Therefore, it gives a good approximation of a binomial distribution for both small and large values. In this case, Poisson distribution is intensively used in quality control cards, queuing theory, telecommunications, etc.
There are various methods for implementing the pseudorandom number generators based on Poisson distribution. The generator proposed by Knuth [20,21] is widely known and actively used by his followers. In Wikipedia [22] it is presented in the following form in an arbitrary pseudo-code language, where parameter α has the notation λ, and the random variable η is equal to k: algorithm poisson random number (Knuth): init: Let L ← e−λ, k ← 0 and p ← 1. do: k ← k + 1. Generate uniform random number u in [0,1] and let p ← p × u. while p > L. return k − 1.
Below is the program code in C# for Microsoft Visual Studio. According to Equation (1), instead of λ, the parameter α is assigned here, which can be designated by any arbitrary value, for example α = 2.0. The function KnuthPoisson() creates stochastic integer numbers k, which are analogous to the random variables η in (1). Their frequency distribution is stored in an array nuK. The function Random.Next() is used as a generator of uniform random variables. The function PoissonP() places the probabilities P(η, α) of stochastic events in an array pEta. To form the distribution, a total N = 2 w = 2 16   //global number of uniform generation } while (p > L); return k − 1; //frequency sum Eta++; } while (snuEta < N); return Eta − 1; In this listing, the columns pK and nuK show the values for frequency and probability obtained by Knuth algorithm. These values correspond well to the analogous ones in the columns pEta and nuEta, which are calculated by Poisson model (1). However, there are some peculiarities that should be addressed here.
The first drawback is due to the fact that string 11 shows 0 by Knuth algorithm. This means that the generator did not create the 11th random variable, although it did create 12th one. This case points out the skipping of the 11th variable. In the theoretical Poisson distribution, this situation is not allowed. For some applications that are not limited to strict constraints, this could be neglected. However, if the generator is used for the comprehensive modeling of real stochastic situations, it is better to avoid this.
The second disadvantage is apparent if Knuth generator is launched repeatedly. The monitoring of the values in columns pK and nuK registers their inconsistency. In probability theory by Kolmogorov axiomatics [2,23] a change in the probabilistic measure in a given space under any circumstances is categorically prohibited. The disturbance of the axioms of a space can make it difficult to interpret the results. This may be crucial when repeated tests are required, for example, in emergency situations, i.e. when it is necessary to reiterate the special cases.
The third limitation of Knuth algorithm is that counter gc, which summarizes the number of generated uniform random variables, turned out to be 197025. The cycle of Knuth generator is arbitrary; hence the value of gc should also be arbitrary. In the current case, value gc = 197025 is almost three times greater than the number N = 65536 of uniform random variables, from which Knuth algorithm generates Poisson stochastic variables. This entails uncontrolled repetitions and skipping of basic random variables together with a loss of their uniformity, which ultimately leads to an insufficient quality for the results obtained.
So, summing up all the aforementioned points, the aim of this article is to propose a generator of stochastic variables in strict accordance with the theory of Poisson distribution by having no excessive and intermediate generations of uniform variables. This is the next step in searching for better algorithms for Poisson stochastic generation and their optimization.

Theory
Poisson stochastic process operates with random variables that linearly depend on a continuous parameter. Usually, such a parameter is the observation time of a stochastic event, but other interpretations are possible as well. In this particular case, an interest is represented both by the time moment t and by the time interval τ following it. The randomness of events in two successive continuous time intervals [0, t] and (t, t + τ] implies [23] that random events in the quantity η could occur during the total time duration [0, t + τ]. If events in the quantity k are observed in the interval [0, t], then a diminution η − k for these events should occur in the half-open interval (t, t + τ]. The first axiomatic restriction is due to the fact that both intervals are independent, and also that the events in them separately occur as the substantive cases. The consequence of this restriction is that the probability of observing the events η on the common interval [0, t + τ] is the joint probability of independent events: In Poisson model the probability P η−k ((t, t + τ]) has a number of serious limitations, which can be formulated as follows: 1.
The probability of events in the time interval (t, t + τ] does not depend on its origin t: 2. The probability of one event in the time interval (0, τ] depends linearly on the length of the interval τ with given intensity λ; and the probability o(τ) of observing other events is negligible: In Equation (4) the notation α = λt (1) is used, which in the theory of probabilities [2] and the theory of random processes is in common use. Equation (4) excludes an observation of two or more events simultaneously in the time interval τ. This makes it possible to simplify it without considering the events with an infinitesimal small probability of a higher order o(τ): Equation (5) allows for reaching the determination of probability of the event absence in the time interval τ: Combining together Equations (2) and (6), the probability of the event absence at the time moment t in the general interval [0, t + τ] could be obtained as follows: This expression (7) leads to the definition of the derivative with respect to probability: The solving of the differential Equation (8) determines the probability of the absence of events at the time moment t, in which the constant c = 1 is derived from the initial condition P 0 (0) = 1. The result is the following: Equation (9) with allowance for Equation (2) and Constraints (5) and (6) admits calculating the probability of a single event P 1 ([0, t + τ]) as follows: By analogy with Transformations (7) and (8), Equation (10) leads to the following differential equation: The solving of Equation (11) determines P 1 (t) with the initial condition P 1 (0) = 0: Performing successively the Transformations (10)- (12) for all variables η ∈ [0, ∞], the distribution of Poisson probabilities P η (λt) with respect to quantity η of random events with intensity λ at the time moment t could be obtained as follows: Since the set of η ∈ H = [0, ∞] of random events in Kolmogorov axiomatics contains σ-algebra, the probability measure P η (α = λt) (13) uniquely determines the cumulative function F H (η, α = λt) of the distribution probabilities: Using a definition of number e x = ∞ k=0 x k /k! for Equation (14), it follows that It should be noted here that a probability space guarantees uniqueness of the determination of the inverse probability distribution function. If any value h of the cumulative distribution function F H (η h , α = λt) = h is given, then a value of the stochastic variable η h can be obtained as the inverse transformation η h = F −1 H (h). Therefore, by specifying the complete uniform random values , it allows uniquely obtaining the stochastic values η of this distribution. This main mathematical model contains the bases for constructing the generators of random variables from given functions of their distribution. Let us use this statement for developing the generator of Poisson stochastic variables. For this it is necessary to get an absolutely complete and uniform generator, which has no repetitions and skipping of random variables. Let us use here the twister generator nsDeonYuliTwist32D [24][25][26][27], which is of such properties.
Below is the program code, in which the twister generator nsDeonYuliTwist32D [26] creates complete set 0 : 2 w − 1 of uniform integer random variables z, having the length of w bits. Function PoissonD() creates an array pEta of Poisson probabilities (13) and an array of corresponding frequencies nuEta (15). The last trailing single frequencies complement an array of frequency distributions nuEta to the completeness 2 w of basic uniform random variables. Therefore, the trailing probabilities pEta are complemented relying on the trailing single frequencies in nuEta. Such a negligible deviation in the rest of the distribution (13) allows for preserving the completeness of generation of Poisson stochastic variables based on initial generation of uniform random variables z ∈ 0 : 2 w − 1 . The values of the cumulative frequency function are located in an array of summarized frequencies snuEta. Inverse function F −1 H (η h , α = λt) is created by using function SearchEta() in accordance with a searching algorithm for the index of element in an array of the cumulative frequencies cnuEta. Program names P060202 and cP060202 are taken by chance.    In this listing, the pEta column contains Poisson probabilities distribution (13). In the next column nuEta, there is a corresponding frequency distribution. The sum of all frequencies snuEta = 4294967296 has to be coincided with generation of the basic uniform random variables having w = 32 bits in the total quantity of N = 2 w = 2 32 = 4294967296 . The counters nuDYG of the last column confirm the complete coincidence of distribution of the generated random variables with the theoretical frequency distribution nuEta.

Construction and Results
Below is class nsDeonYuliCPoissonTwist32D, in which the random variables are created in accordance with Poisson distribution (13). This class is derived over the base one nsDeonYuliTwist32D of the twister generator of uniform random variables [24][25][26][27], which in DieHard Tests [28][29][30][31][32] shows an absolute uniform distribution. An example of generation of Poisson stochastic variables is given here later in program P060302.  This result shows a stochastic sequence of random variables generated by twister generator nsDeonYuliCPoissonTwist32D. The direct calculation by this listing confirms that all the elements including the random variables, their probabilities and frequencies do indeed satisfy Poisson distribution. Similar results could be obtained for other quantities as well, for example with a length of w ≤ 32 bits.

Discussion
As mentioned at the beginning of this article, Poisson distribution has basic properties of initial probabilistic moments in terms of mathematical expectation and dispersion. The mathematical expectation for this type of a distribution characterizes the average number of successful results at any interval. Usually, it is determined on a basis of the experimentally obtained data for a certain situation. Next, if the mathematical expectation is determined, then the dispersion is known also because of the distribution properties of Poisson probabilities. If it turns out that the values of the mathematical expectation and the dispersion are sufficiently close, then the hypothesis of the distribution of certain random variables in accordance with Poisson law is correct. However, if there is a meaningful difference in the obtained values of these characteristics, this would testify against the hypothesis of Poisson distribution of the given random variables.
Therefore, first of all, it is necessary to confirm two basic aforementioned properties of Poisson distribution on equality of parameter α to mathematical expectation and dispersion. Below is the program code that validates this. The generator in it creates the random variables in quantity N = 2 w = 2 32 = 4294967296. Program names P060402 and cP060402 are chosen by chance.  Further, a general discussion should also supplement the estimates of possible generation of the random variables with respect to Poisson distribution. To do this, let us refer to the capabilities of the basic twister generator nsDeonYuliTwist32D, which is used here for uniform random variables creation. For a given length of w bits it realizes several complete twisting sequences. Initial sequence contains N = 2 w non-repeating numbers distributed uniformly and randomly in interval [0 : 2 w − 1]. For utilization, the constants a and c of the twister generation of the random variable x i = (ax i−1 + c)mod 2 w obtained from the value of the previous variable x i−1 are used. When the generator completes the creation of one series consisting of N = 2 w random variables, it automatically proceeds to the creation of the next twisting series, in which N = 2 w elements are obtained as well. So, for each pair of twister constants a and c, the twisting uniform sequences in quantity N T could be created: Consequently, one complete twisting cycle (16) with unchanged a and c realizes the following quantity N s for uniform random variables that allows the creation of the same number of Poisson stochastic variables: To obtain a complete cycle of all Poisson stochastic series with quantity N s = w·2 2w of the random variables in each complete twister (17), it is necessary to take into account the varieties of coefficients a and c in the twister transformation x i = (ax i−1 + c)mod 2 w . The values of these coefficients must not exceed the interval limit a, c ∈ [0 : 2 w − 1] of all uniform variables in the single series. Quantity N a of the coefficient a is defined as: During the generation of uniform random variables, the values of the coefficients c have to be odd, i.e., c mod 2 0. Their quantity N c is defined as the following: Collecting Equations (16)- (19) together, the estimate for the total number N sac of the random variables is defined in the following manner: N sac = N s ·N a ·N c = w2 2w 2 w−2 w w−1 = w·2 4w−3 .
Finally, the information concerning non-repeatable cycle N I has the following estimation: N I = 2 wN sac = 2 w 2 2 4w−3 .
As an example, let us get the real values of these estimations for the bit length w = 32. In this case, each series contains N = 2 32 = 4294967296 Poisson stochastic variables, and in each of these series Poisson distribution is observed absolutely. In this case, the total number of generated Poisson stochastic variables is N sac (w = 32) = 32·2 4·32−3 = 2 5 ·2 125 = 2 130 , and the value of the non-repeatable cycle (21) is defined as N I (w = 32) = 2 2 5 2 130 = 2 2 135 . Therefore, the complete discrete simulation of the random variables with Poisson distribution using the aforementioned basic twister generator confirms the important properties in terms of mathematical expectation and dispersion. Moreover, an automatic extension of the series of initial uniform random variables extends significantly the periods of non-repeatability (Equations (20) and (21)) for the series of Poisson stochastic variables. This notably exceeds the features of the known generators, which bases the probabilistic convergence algorithm.

Conclusions
An analysis of the source material shows that algorithms for generation of Poisson stochastic variables according to the probabilistic convergence technology lead to different realizations of distributions. Moreover, the skipping of elements in such distributions may also occur, which is inappropriate in the theory of Poisson stochastic processes. Since the quality of the generators depends on the basic generations used for uniform random variables, it has been proposed here to use the twister generator nsDeonYuliCPoissonTwist32D to ensure the completeness of technology of the cumulative array of frequencies in Poisson space. This approach allows for reducing the time of operations and improving the quality of generation. In the discrete probabilistic Poisson space, the test results confirmed the complete coincidence of the distributions of the obtained stochastic variables with the ones received in theoretical modeling. Moreover, an automatic tuning of the parameters of the basic twister uniform generator nsDeonYuliTwist32D allows obtaining a significant increase in the overall period of non-repeatable generation of Poisson stochastic variables.
Author Contributions: Paper writing, conceptualization and methodology, programming and analysis, investigation and data curation, algorithm improvement were done by A.F.D. Paper writing, conceptualization, validation, original draft preparation, reviewing and editing, project administration and supervision were done by Y.A.M. All authors have read and approved the final manuscript.
Funding: This research received no external funding.