Computer Science and Engineering
p-ISSN: 2163-1484 e-ISSN: 2163-1492
2015; 5(2): 25-29
doi:10.5923/j.computer.20150502.01
Wael M. F. Abdel-Rehim1, Ismail A. Ismail2, Ehab Morsy3
1Department of Mathematics and Computer Science, Faculty of Science, Suez University, Suez, Egypt
2College of Computers and Informatics, Misr International University, Cairo, Egypt
3Department of mathematics, Suez Canal University, Ismailia, Egypt
Correspondence to: Wael M. F. Abdel-Rehim, Department of Mathematics and Computer Science, Faculty of Science, Suez University, Suez, Egypt.
| Email: |  | 
Copyright © 2015 Scientific & Academic Publishing. All Rights Reserved.
In this paper, motivated by certain practical applications such as Monte Carlo simulation and cryptography. On the other hand, Pseudo-random numbers are often required for simulations performed on parallel computers. We implement the classical Poker test using parallel MATLAB with OpenMP (Open Multi-Processing) using MEX-file. After that, we compares the performance of the implementation with that implemented the Poker test in parallel with MATLAB using MEX-file with multithreading. We show that the running time of implementing the Poker method using parallel MATLAB with OpenMP is significantly less than that using MEX-file (MEX stands for MATLAB Executable) with multithreading, especially when the number of random numbers is sufficiently large.
Keywords: Poker test, Randomness, Cryptography, Parallel random numbers test, MATLAB Multithreading, OpenMP
Cite this paper: Wael M. F. Abdel-Rehim, Ismail A. Ismail, Ehab Morsy, Testing Randomness: The Original Poker Approach Acceleration Using Parallel MATLAB with OpenMP, Computer Science and Engineering, Vol. 5 No. 2, 2015, pp. 25-29. doi: 10.5923/j.computer.20150502.01.
 It is well known that the number of hands a poker test can apply with is not restricted to five [5]. In particular, Poker test that uses four hands is more convenient to be applied to certain applications such as simulation(see [16]), and cryptography (see [2], [17]) in which we need to generate random integers or a random sequence of bits. For example, in cryptography, secret keys (used for encryption of messages or other purposes) are generated using random number generators (RNGs) (see [17]). Thus we applied Poker test to bit streams (typically represented by a 32-bit or 64-bit unsigned integer) rather than floating point numbers, and since 64 bits is not evenly divisible by five we use the closest number that divides 64: four. That is, the generated sequence of random numbers is divided into segments of four bits (see [18]). Given a sequence of n random numbers to be tested, it is shown that there is a limit based on n as to how large the value of k can be [19]. On the other hand, most practical applications apply poker test with different values of k in order to ensure that the underlying sequence is truly random [20].Some cryptographic algorithms using block cipher take blocks, or keys with different sizes 128, 192, or 256 bits. Therefore, if the block or the key size is 192, we find that they are not evenly divisible by five or four, however divisible by two. Therefore, series of pseudorandom numbers generated is divided into parts, each consisting of two bits. This encourages us to apply Poker test with hands of two numbers instead of hands of three, four or five numbers, especially in applications involving testing the randomness of a sequences of bit such as cryptography.Motivated by increase speed of the test we also implemented the Poker test in parallel with MATLAB using MEX-file with one, two, three and four threads, reducing the execution time of the test (see [21]).A Chi-square test is based on the number of quintuple in each category. We count the number of occurrences in each k-tuples, and then use a chi-square analysis against the theoretical probabilities to determine whether the stack represents a fair poker deck. We computed the theoretical probabilities of some categories two (k=2), three (k=3), five (k=4) and seven (k=5) categories (see [18, 22, 23, 24]).
It is well known that the number of hands a poker test can apply with is not restricted to five [5]. In particular, Poker test that uses four hands is more convenient to be applied to certain applications such as simulation(see [16]), and cryptography (see [2], [17]) in which we need to generate random integers or a random sequence of bits. For example, in cryptography, secret keys (used for encryption of messages or other purposes) are generated using random number generators (RNGs) (see [17]). Thus we applied Poker test to bit streams (typically represented by a 32-bit or 64-bit unsigned integer) rather than floating point numbers, and since 64 bits is not evenly divisible by five we use the closest number that divides 64: four. That is, the generated sequence of random numbers is divided into segments of four bits (see [18]). Given a sequence of n random numbers to be tested, it is shown that there is a limit based on n as to how large the value of k can be [19]. On the other hand, most practical applications apply poker test with different values of k in order to ensure that the underlying sequence is truly random [20].Some cryptographic algorithms using block cipher take blocks, or keys with different sizes 128, 192, or 256 bits. Therefore, if the block or the key size is 192, we find that they are not evenly divisible by five or four, however divisible by two. Therefore, series of pseudorandom numbers generated is divided into parts, each consisting of two bits. This encourages us to apply Poker test with hands of two numbers instead of hands of three, four or five numbers, especially in applications involving testing the randomness of a sequences of bit such as cryptography.Motivated by increase speed of the test we also implemented the Poker test in parallel with MATLAB using MEX-file with one, two, three and four threads, reducing the execution time of the test (see [21]).A Chi-square test is based on the number of quintuple in each category. We count the number of occurrences in each k-tuples, and then use a chi-square analysis against the theoretical probabilities to determine whether the stack represents a fair poker deck. We computed the theoretical probabilities of some categories two (k=2), three (k=3), five (k=4) and seven (k=5) categories (see [18, 22, 23, 24]). Where
Where  denote the Stirling number of the second kind (see [25]) (the number of ways to partition a set of k elements into exactly r parts). The Stirling number can be computed using a well known formula.Then different hands obtained can be compared to what is expected using the chi-square test to see how far the data has strayed from the theoretical distribution.
 denote the Stirling number of the second kind (see [25]) (the number of ways to partition a set of k elements into exactly r parts). The Stirling number can be computed using a well known formula.Then different hands obtained can be compared to what is expected using the chi-square test to see how far the data has strayed from the theoretical distribution.| 
 | 
| 
 | 
|  | Figure 1. Speedup gained by implementing the classical Poker test on two threads and Using OpenMp using parallel MATLAB | 
|  | Figure 2. The classical Poker test pseudo-code algorithm |