A Better Approach to Generating Random Numbers

Received: April 10, 2019 Revised: June 12, 2019 Accepted: July 17, 2019 Published online: September 11, 2019 The term random number has been used by many scholars to explain the behaviour of a stochastic system. Many of such scholars with statistical or mathematical background view it as an organized set of numbers produced by a function in a numerical way in which the next number to be produced is unknown or unpredictable. This paper produced software that generates a sequence of random number and also compared the algorithm with the commonly used method of random number generator. The three most common methods selected were the Mid Square method, Fibonacci method and Linear Congruential Generator Method (LCG). The result shows that the LCG provides a more acceptable result in terms of speed, long cycle, uniformity and independenceApplications of this random numbers can be seen in Monte Carlo simulations, simulation or modelling, password generation, cryptography, and online games.


Introduction
Random number is a set of numbers produced by a function in a numerical pattern in which the next number to be produced is unknown or unpredictable (Shakir, Mohd and Zuraifah 2016;Kale 2013). There are basically two types of random numbers: Pseudo Random Number (PRNG) and True Random Number (TRNG). The Pseudo Random Number uses seed value for its generation Maheshwari, Gupta, Sharma and Chauhan 2014).While the True Random Number doesn't use any seed value and the number generated has no defined pattern (Katyal, Mishra and Baluni 2013).This paper tries to explore Pseudo random numbers, the different methods of generating them (Mid-Square, Fibonacci Method and Linear Congruential Method). It is also actually looks at the advantages and disadvantages of each method in terms of speed, independence, reproducibility and uniformity.
The application of Random Number can be seen in many disciplines especially in Computer Science, Mathematics and Statistics (Li 2012;Rahman, Xiao, Forte, Zhang, Shi & Tehranipoor 2014;Tong, Liu, Zhang, Xu & Wang 2015). The impactis greatly felt in optimization, modeling, simulation, numerical analysis, selection and cryptography.

Related Literature
One cannot talk about Random Number without acknowledging the work of John Von Neumann who first introduced the Mid-Square method of generating random number in 1946. This method brought a lot of excitement to scholars interested in Random Number Generator in those days (Li 2012). In this approach, every middle value becomes a seed value in the next iteration.
The Table 1 below shows how this method works. The seed value 76 is selected arbitrary based on the discretion of the user. The generation continues until the value of N 2 become less than 4 digits or zero (0). This method has a lot of disadvantages e.g. it is statistically unsatisfactory, relatively pp.30 slow, produce short cycle and no correlation between the initial seed and the length of the sequence of random numbers (Li 2012). The attempts to mitigate the shortcoming or drawback of Mid-Square method give rise to the Fibonacci method. The Fibonacci method give rise to Fibonacci series. This is named after the founder of this method in 1950's, this renowned mathematician called Leonardo Pisano believes that for every integer n≥0, Fibonacci sequence {f n } is defined by the second order linear recurrence relation of F n+2 = F n+1 , F n where F 0 = 0 and F 1 = 1. This method has been accepted in many scientific researches. The Fibonacci sequence is given by F n = 0,1,1,2,3,5,8,13………n. Any change in the initial value or recurrence relation or both results to further generalized  (a) The Initialization: selecting the initial value has been very challenging since the cycle directly or indirectly depends on the initial value or conditions. Results from the series totally depends on the initial value. (b) Lack of theory to guides every procedure involved in the method. There has never been an established theory aside the statistical test which many researchers believe is insufficient for generalization. (c) Despite the fact that the method can reproduce same results when tried severally with a same limited value, this method lack uniformity and is poorly distributed (Rubinstein and Kroese 2011).
To challenge the existing and trending Fibonacci method, a congruential method was established by Lehman in 1949. Even though it lacks popularity by that time, the good properties of this method, made it suitable for programmer interested in developing random number to be used for optimization, modeling and simulation experiments. In the early 1960's (Li 2012 andTirdad 2010). This method was believed to be very easy to use and understand, its implementation is easy and fast at the same time. It integrates linear equation called the linear congruential generator (LCG). This algorithm proves a sequence of pseudo-Random numbers based on discontinues piecewise linear equation (Gurubill and Garg 2010).
The Generator is Defined by a Recurrence Relative m, the modulus; m > 0. a, the multiplier; 0 ≤ a > m. c, the increment; 0 ≤ c < m. X 0 , the starting value; 0 ≤ X 0 < m. The LCG has proven to be easy to implement and produced a PRNGs that have long cycle.

Benchmarking the Three PRNG Discussed Against Each Other
This section explores the advantage, disadvantage and properties of the three PRNG identified in the study.

Middle Square Method
Consider the example in Table 3 below, the middle square method is demonstrated using 8765as a seed value.

Fibonacci Generator
Consider the example in Table 3 below, the Fibonacci method which begin with either 0 or 1 More of the numbers can be generated using different initial values. The Figure 1 below shows how Pascal Triangles can be used to generates Fibonacci Random numbers. (Gary 2012).  Following the above tables, the following comparison were made and we decided that LCG provides an enhanced result in comparison to other PRNGs.

Feasibility Study
According to findings, there are random number generators available on the internet and there is also an increasing demand for efficient and reliable random number generators that can generate a sequence of random numbers for statistical and simulation purposes respectively. The fact finding techniques used in order to study the existing system includes: observation, interview and research.
Observation: This technique was used to obtain the functionalities of the existing system. This takes into consideration the use of some random number generators and how they present their outputs, coupled with the number of digits they generate as a single random number.
Interview: Using this method, university students from some of the departments in ADSU were interviewed. Precisely students from Biological Sciences Department, Department of Accounting, Mathematics, Computer Science Departments and Economics. They welcomed the idea of having an automatic random number generator for experiment purposes. Their response was captured in a questionnaire.
Secondary Sources: Various academic journals were reviewed by the researcher the outcome revealed the need for an efficient and reliable random number generator which could be used for general purposes. This however, prompted the researcher to fill the discovered gap.

Problems of the existing methods for generating random numbers.
i The existing system is non reproducibility: this is a situation where the system cannot give the same results even when all the initial conditions are met. ii Further, the existing system tend to de-generate: this means the system tends to give a static or zero result after certain time or circle of generating the numbers. iii The existing system lack speed; very slow in generating the numbers.example the manual method of generating Radom numbers of tossing a dice, shuffling of cards, etc. the existing method is slow more especially when a large numbers of the random numbers are needed.

Proposed system
Random number is a set of numbers produced by a function in a numerical pattern in which the next number to be produced is unknown or unpredictablewhich can be used precisely for simulation and mathematical purposes (Shakir, Mohd and Zuraifah 2016;Kale 2013). This system is a webbased application which runs on a browser to produce a random number. The generated random numbers however can be printed,

System flowchart
The Figure 2 below is a flow chart illustrating how the new system is to be defined. The system captures values as inputs, generate numbers and give results.

Technologies for Development
Learning Management System (LMS) is an online web based platform for managing learning. Therefore, the following technologies are being used for the development of the system the technologies used in developing this system includes: i PHP stands for Php: Hypertext Preprocessor which is a scripting language for server side backend development. ii HTML, CSS, Ajax, and JavaScript for frontend iii Bootstrap: is a framework used for responsive frontend web design.

Results
The Figure 3 below shows the system Homepage. Which is the first page after launching the system pp.33 The Figure 4 below shows a sequence of generated random numbers when the button "generate" was clicked for the first time. The Figure 5 below shows a sequence of generated random numbers when the button "generate" was clicked for the second time.

Discussions of Results of Implementation
This system as illustrated above, shows the different implementation interfaces or results of the system. The first figure Figure 3 shows the system home page where the button to be clicked when one wants to generate random numbers appears along with the date the random numbers were generated. The second figure Figure 4 and the third figure Figure 5 shows the random numbers generated as a result of clicking on the button. The random numbers can therefore be printed as hard copy for simulation or statistical experiments respectively. Whenever one needs a different sequence of random numbers, one needs to click on the button "generate" and the random numbers will be generated.

Summary
Random number is a set of numbers produced by a function in a numerical pattern in which the next number to be produced is unknown or unpredictable.
The main aim of this paper is to develop a software that can generate a sequence of random numberwhich can be used precisely for simulation, cryptography, games and mathematical purposes. php and Mysql are used in designing the software. The system was tested and found to be more efficient and effective in generating random numbers.

Conclusion
Before looking at this research work, the improvement, efficiency and quick service that can be derived from the system has over weighted the manual method of generating random numbers such as shuffling of cards and rolling a dies. The program is user friendly and can be used by any authorized person. With the evolution of computer technology, its importance can be seen in every aspect of human endeavors.

Recommendations
1. University students especially those in Department of computer science, should adopt this software that can generate a random number for the process of getting the result especially during experiments involving the use of random numbers. 2. Programmers should adopt this software and generate random number to be used for cryptography, optimization, modelling and simulation. 3. Casino and gambling Gaming Industry should adopt this softwareto produce an output of their games

Further Studies
More researches be done on other methods of generating random numbers. Any results obtained should be pp.34 benchmarked against this application to measure reproducibility, uniformity and independence. Also, criteria for selecting seed value should be developed so that it will not be at the discretion of the user.