Professional Documents
Culture Documents
Implementing The Classical Poker Method For Testing Randomness
Implementing The Classical Poker Method For Testing Randomness
Abstract: The problem of testing randomness is motivated by the need to evaluate of the quality of different random number
generators used by many practical applications including computer simulations, cryptography, and communications industry.
In particular, the quality of the randomness of the generated numbers affects the quality of such applications. In this paper we
focus on one of the most popular approaches for testing randomness, Poker test. Two versions of Poker test are known: the
classical Poker test and the approximated Poker test, where the latter has been motivated by the difficulties involved in
implementing the classical approach at the time it is designed. Given a sequence of n random numbers to be tested, the basic
Poker approach divides this sequence into groups of k=5 numbers, observes which of the possible patterns is matched by each
quintuple, computes the occurring probability of each of these patterns, and finally applies Chi-square test to check the
randomness of such sequence. In [1], we showed that such approach can be implemented with no significant extra running
time compared with the approximated approach. Motivated by certain applications we also implemented the Poker test with
hands of four numbers (k=4) instead of five, reducing the running time of the test [2]. Moreover we implemented the Poker
test with hands of three numbers (k=3) instead of four or five numbers, reducing significantly the running time of the test [3].
Furthermore we implemented the Poker test with hands of two numbers (k=2), It was optimized for testing the randomness of
sequences of sufficiently small sizes.
In this paper, motivated by certain practical applications such as cryptography and Monte Carlo simulation [7]. On the other
hand, Pseudo-random numbers are often required for simulations performed on parallel computers [7]. We implement the
classical Poker test in parallel with MATLAB using MEX-file with one, two, three and four threads and compare the
performance. We show that the speedups of the implementation using two threads are close to three threads and both of them
are greater than one thread. However, with four threads is significantly greater than one, two and three threads.
Keywords: Poker test, randomness, cryptography, secret keys, parallel random numbers test, Matlab Multithreading.
1. Introduction
Measuring the quality of randomness of a given
sequence is a crucial problem that significantly affects
the quality of many practical applications such as
distributed algorithms, cryptography [17], statistical
sampling and computer simulation, as example pseudorandom numbers used in Monte Carlo calculations [7].
In other words, the quality of such applications depends
on generating unpredictable (random) sequence of
quantities. From the practical point of view, such
sequence must be of sufficiently large size in the sense
that the probability of any particular value being
selected must be sufficiently small in order to prevent
an adversary from optimizing a search scheme based on
such probability.
2. Poker test
In this section we present in details the two versions of
Poker test, the classical Poker test and the
approximated Poker test.
Pattern
ABCDE
AABCD
AABBC
AAABC
AAABB
AAAAB
AAAAA
Probability
0.3024
0.5040
0.1080
0.0720
0.0090
0.0045
0.0001
d ( d 1)...( d r 1) k
k
d
r
(1)
3. Experimental results
In this section we implement the classical Poker test
and the corresponding modified version in parallel
with MATLAB using MEX-file. We evaluate both
versions of the test by implementing programs using
C++ code that create random numbers. After that, we
use MATLAB using MEX-file to count the occurrence
of these differences or count number of occurrences,
then classified each to possible type of poker hand.
Finally, it determines the chi-square. We have
compared the classical Poker test in parallel with one,
two, three and four threads and compare the
performance. The experimental results are reported on
Laptop Core i5 2.50 GHz CPU, 4GB of RAM, 3M of
Cache and, MATLAB 8.1 (R2013a).
Observed
number of
hands (O)
Expected
number of
hands (E)
(O E)2 / E
604219
1008237
216514
143808
9087
193
17942
604800
1008000
216000
144000
9000
200
18000
0.5581
0.0557
1.2231
0.2560
0.8410
0.2450
0.1869
2000000
2000000
X2 = 3.37
1000
5000
10000
50000
100000
500000
1000000
5000000
10000000
No of
hands
200
1000
2000
10000
20000
100000
200000
1000000
2000000
Original
Poker's test
Chi-square
value
7.93
7.1
3.42
3.63
3.51
7.64
2.63
1.65
3.37
Modified
approach
Chi-square
value
3.28
6.85
2.7
2.85
3.28
2.78
1.79
1.41
1.18
Cell/Poker
Hand
1 different
2 different
3 different
4 different
5 different
Sums
Observed
number of
hands (O)
193
27029
360322
1008237
604219
2000000
Expected
number of
hands (E)
200
27000
360000
1008000
604800
2000000
(O E)2 / E
0.2450
0.0311
0.2880
0.0557
0.5581
X2=1.18
Random
No
1000
5000
10000
50000
100000
500000
1000000
50000000
10000000
1
Thread
27
29
46
62
78
94
156
188
265
2
Thread
15
16
32
47
67
79
140
172
234
3
Thread
15
15
31
46
62
77
125
141
203
4
Thread
15
15
24
31
41
47
72
85
109
Random
No
1000
5000
10000
50000
100000
500000
1000000
50000000
10000000
Speedup
for
2
thread
1.80
1.81
1.44
1.32
1.16
1.19
1.11
1.09
1.13
Speedup
for
3
thread
1.80
1.93
1.48
1.35
1.26
1.22
1.25
1.33
1.31
Speedup
for
4
thread
1.80
1.93
1.92
2.00
1.90
2.00
2.17
2.21
2.43
1.
2.
3.
4.
1.
2.
3.
4.
5.
7. Conclusion
We have been studied Poker test, in parallel with
MATLAB, one of the most popular approaches for
testing randomness. In particular, we have been
discussed the Poker test in parallel with MATLAB
using MEX-file with one, two, three and four threads
and compared the performance. From the computations
point of view, we have been compared the performance
of implementing Poker approach in parallel with
MATLAB. We show that the speedups of the
implementation using two threads are close to three
threads and both of them are greater than one thread.
However, with four threads is significantly greater than
one, two and three threads, especially when the number
of random numbers is sufficiently large.
References
[1] Abdel-Rehim, Wael M. F., Ismail, Ismail A.,
Morsy, Ehab, 2012. Implementing the classical poker
approach for Testing Randomness, (Submitted)
[2] Abdel-Rehim, Wael M. F., Ismail, Ismail A.,
Morsy, Ehab, 2012. Testing randomness: Implementing
poker approaches with hands of four numbers.
International Journal of Computer Science Issues, Vol.
9, Issue 4.
[3] Abdel-Rehim, Wael M. F., Ismail, Ismail A.,
Morsy, Ehab, 2012. Testing Randomness: Poker Test
with Hands of Three Numbers. Journal of Computer
Science 8 (8): 1353-1357
[4] Abdel-Rehim, Wael M. F., 2012. Testing
randomness: Poker test with hands of two numbers.