Generating High-Quality Random Numbers By Cellular Automata With PSO

backporcupineAI and Robotics

Dec 1, 2013 (3 years and 4 months ago)


Generating High-Quality
Random Numbers By Cellular Automata With PSO

Qianfeng Wang, Songnian Yu, Wang Ding, Ming Leng
School of Computer Engineering and Scie
nce, Shanghai University, 200072 Shanghai, China,,,


The random numbers are needed in variety of
applications, yet finding good random number is a
hard task. In this paper, a novel particle swarm
cellular automata (PSCA) is proposed. Further, PSCA
are applied in pseudorandom number generation. The
produced random numbers pass all tests of diehard
and Federal Information Processing Standards (FIPS)

The outputs have good performance in
statistical tests. Randomness test results on our Pseudo
Random Number Generators (PRNG) show that they
are better than one-dimensional (1D) CA PRNGs and
can be comparable to two-dimensional (2D) ones.

1. Introduction

Random numbers are very important for a variety of
purposes, such as Monte Carlo techniques, simulated
annealing and Brown dynamics. These simulation
methods depend critically on the quality of the random
numbers, as measured by appropriate statistical tests.
When a large number of random numbers have to be
generated, the computational efficiency is also very
important. Built-in devices for VLSI circuits are also
another application area of random numbers. In this
case, as well as for fine-grained massively parallel
computers and for on-board applications, it is essential
that the random number generator also be amenable to
hardware implementation in terms of area, number of
gates, and complexity of the interconnections.
There are several deterministic algorithms for
producing random numbers. But they have been
proposed to date. In Section 2, we will review the
principal pseudo-random number generator methods
(PRNG). In section 3, we will concentrate on
generating pseudo-random sequences by using cellular
automata (CA). The new PRNG which is constructed
by CA with PSO is described in Section 4. Our test
results are showed in Section 5

2. Random Number Generators

A pseudorandom number generator (PRNG) is an
algorithm for generating a sequence of numbers that
approximates the properties of random numbers. The
sequence is not truly random in that it is completely
determined by a relatively small set of initial values,
called the PRNG's state. Although sequences that are
closer to truly random can be generated using hardware
random number generators, pseudo-random numbers
are important in practice for simulations (e.g., of
physical systems with the Monte Carlo method), and
are central in the practice of cryptography. The
generator is exercised by steps, and two things occur
concurrently during each step: there is a transformation
of the state information, and the generator outputs a
fixed size bit string. The generator seed is simply the
initial state information. With any pseudo-random
generator, after a sufficient number of steps, the
generator comes back to some sequence of states that
was already visited. Then, the period of the generator is
the number of steps required to do one full cycle
through the visited states.
Careful mathematical analysis is required to have
any confidence a PRNG generates numbers that are
sufficiently "random" to suit the intended use. Random
numbers are needed in a variety of applications, yet
finding good random number generators is a difficult
task [1]. All practical methods for obtaining random
numbers are based on deterministic algorithms, which
are why such numbers are more appropriately called
pseudo-random, as distinguished from true random
numbers resulting from some natural physical process.
In the following we will limit ourselves to uniformly
distributed sequences of pseudo-random numbers;
however, there are well-known ways for obtaining
sequences distributed according to a different
distribution starting from uniformly distributed ones.
In practice, the output from many common PRNGs
exhibit artifacts which cause them to fail statistical
pattern detection tests. These include, but are certainly
not limited to (1) Shorter than expected periods for
some seed states; such seed states may be called 'weak'
Fourth International Conference on Natural Computation
978-0-7695-3304-9/08 $25.00 © 2008 IEEE
Fourth International Conference on Natural Computation
978-0-7695-3304-9/08 $25.00 © 2008 IEEE
Fourth International Conference on Natural Computation
978-0-7695-3304-9/08 $25.00 © 2008 IEEE
DOI 10.1109/ICNC.2008.560
Fourth International Conference on Natural Computation
978-0-7695-3304-9/08 $25.00 © 2008 IEEE
DOI 10.1109/ICNC.2008.560
in this context (2) Lack of uniformity of distribution (3)
Correlation of successive values (4) Poor dimensional
distribution of the output sequence (5) The distances
between where certain values occur are distributed
differently from those in a random sequence
distribution. Defects exhibited by flawed PRNG range
from unnoticeable to absurdly obvious.
Random number generators must possess a number
of properties if they are to be useful in lengthy
stochastic simulations such as those used in
computational physics. One of the most popular
methods for generating random numbers is the linear
congruential generator. It use a method similar to the
folding schemes in chaotic maps. The general formula

( )
= a mod.0,0,
n n
X X m m
a m
≥ >
< <
+ c n

The value m > 0 is called the modulus, a is the
multiplier, and c is an additive constant. Ref. [2]
describes in great detail how to pick suitable values for
these parameters. The quality of the generator is
strongly dependent upon the choice of these constants
(a significant part of Knuth's chapter on random
numbers is dedicated to this topic). The method is
appealing however, because once a good set of the
parameters is found, it is very easy to program [3]. One
fairly obvious goal is to make the period (the time
before the generator repeats the sequence) long, this
implies that m should be as large as possible. This
means that 16 bit random numbers generated by this
method have at most a period of 65,536, which is not
nearly long enough for serious applications.

3. Introduction to Cellular Automata

Cellular automata (CA) is a decentralized
computing model providing an excellent platform for
performing complex computation with the help of only
local information [4]. The concept of CA was initiated
in the early 1950's by J. Von Neumann and Stan Ulam.
Von Neumann showed that a cellular automaton can be
universal. They are dynamical systems in which space
and time are discrete. A one-dimensional cellular
automaton consists of two things: a row of "cells" and
a set of "rules". There are also two-dimensional
cellular automata, which use rectangular grids of cells.
Each of the cells can be in one of several "states". The
number of possible states depends on the automaton
[5]. Think of the states as colors. In a two-state
automaton, each of the cells can be either black or
white. Of course, you might just as easily use purple
and orange to represent the states, if you thing that's
prettier. In a three-state automaton, the states might be
black, red, and blue.
A CA doesn't just sit there. Over time, the cells can
change from state to state. The cellular automaton's
rules determine how the states change. It works like
this: When the time comes for the cells to change state,
each cell looks around and gathers information on its
neighbors' states [6]. Exactly which cells are
considered "neighbors" is also something that depends
on the particular CA. Based on its own state, its
neighbors' states, and the rules of the CA, the cell
decides what its new state should be. All the cells
change state at the same time. You should think of the
row of cells as a miniature "world" that runs through a
sequence of "years" or "generations." At the end of
each year, all the cells simultaneously decide on their
state for the next year. When a CA is simulated on a
computer, it's a good idea to have two rows of cells.
One row is the actual world; the other is used as a
convenient place for computing the cells' states in the
next year. After all the cells have been processed, the
new world can replace the old. [7]

4. Cellular programming with PSO

The particle swarm is an algorithm for finding
optimal regions of complex search spaces through the
interaction of individuals in a population of particles.
Particle swarm optimization is similar to a genetic
algorithm [8] in that the system is initialized with a
population of random solutions. It is unlike a genetic
algorithm, however, in that each potential solution is
also assigned a randomized velocity, and the potential
solutions, called particles, are then “flown” through
hyperspace. In this paper we use PSO optimize the
rules of CA automatically. In our algorithm, each CA
is also a particle. And the fitness used is described as
The fitness measure used here is the entropy Eh: let
k be the number of possible values per sequence
position (in our case CA states) and h a subsequence
length. Eh (measured in bits) for the set of
probabilities of the possible subsequences of length h
is given by:

j = 1
E = - lo g 2
h j h j

where are all the possible subsequences of length h
(by convention, when computing entropy). The
entropy attains its maximal value when the
probabilities of all possible subsequences of length h
are equal to in our case k=2 and the maximal entropy is
Eh =h.
First we assign the initial rule configuration to each
CA randomly, in this configuration, make the CA run
M time steps in accordance with specified rules and
calculate the CA state sequence entropy, and then
another with the same body type running M time step,
each cellular accumulation of entropy, and repeat this
process C times.
Make the entropy of each CA as the fitness of PSO,
in accordance with the PSO algorithm to amend the
basic principles of cellular rules. Finally we determine
whether to meet conditions for the termination of PSO
to meet the stop, not satisfied with the rules of each
cell of each gene encoding a mutation probability P
implementation mutation operator operation to a new
cellular rules. Each cell after the entropy is 0 home, a
new round of the PSO evolutionary computation.
The algorithm can be summarized as follows:
(1) Initiate rule tables randomly, and assign each
CA a rule, set the fitness of each CA 0.
(2) Initiate state counter.
(3) Generate an initial configuration of the state
randomly, make the CA run M time step in this
(4) Calculate the fitness of each CA, and increase
configuration counter.
(5) If the total running steps is equal to c, that is c
Mod C = 0, go to the next step, or else go 3;
(6) Update the CA rules by using PSO after
calculating the fitness of each CA
(7) If the conditions are not satisfied with the
termination, go to 2, or stop.

5. Analysis of the Test Results

In this section we describe the results of applying
the PSCA model of random number generators by
Diehard test suit. Diehard is one of the standard
random number test suits and has been wildly used in
the fields of testing random numbers recent days.
First we tested the following uniform CA rules: 30,
90, 105 wihtout the participation of PSO. Taking into
account all the Diehard tests, we can conclude the
following: rule 105 is the best RNG (among the
uniform rules), followed by rules90,30. All these CAs
failed the bitstream and OPSO tests. With respect to
the OQSO test, rule 30 had always failed, while the
other rules sometimes produced good (passing) strings.
A periodicity of the p-values was detected in all cases.
We conclude that on the whole, uniform CAs comprise
fairly good generators, but they do not compare well
with standard classical ones (see table 1). Then we
tested the CAs above with PSO, the results show good.
All CAs with PSO pass all the Diehard tests. And no
relations were found between the sequences generated
by each CA with PSO. Before studying sequence
cross-correlations, we submitted each of the three
sequences separately to the Diehard test suite in order
to assess their randomness. The results were good and
comparable to the single-sequence ones described

Table 1. A generator fails to pass a test if the p-
value scores are very close to zero or to one, to six or
more decimal places. Diehard p-value results for the
CGL, RAN3 random number generators and uniform

Test Name GGL RAN3 30 90
Birthday spacing
0.980 1.000 1.000 1.000
permutation 1 0.422 0.578 1.000 1.000
permutation 2 0.951 0.047 1.000 1.000
Binary rand
0.368 0.840 1.000 1.000
Binary rand
1.000 0.958 1.000 1.000
Binary rand 6*8 0.510 0.001 1.000 1.000
Count the ones 1.000 0.542 1.000 1.000
Parking lot 0.510 0.204 1.000 0.381
1.000 0.911 1.000 1.000
3D sphere 0.546 0.663 1.000 0.631
Squeeze 0.228 0.579 1.000 1.000
Overlapping sum 0.849 0.722 0.511 0.181
Run up 1 0.838 0.123 0.880 0.078
Run up 2 0.003 0.638 0.121 0.940
Run down 1 0.504 0.057 0.976 0.602
Run down 2 0.886 0.045 0.703 0.730
Craps number of
0.219 0.281 1.000 0.021
Craps number of
0.481 0.250 1.000 0.328

Table 2. Diehard p-value test results for PSO and
uniform CAs with PSO

Test Name 30 90 105
Birthday spacing 0.296 0.37 0.705
Overlapping permutation 1 0.315 0.131 0.831
Overlapping permutation 2 0.619 0.127 0.816
Binary rand 31*31 0.469 0.713 0.021
Binary rand 31*32 0.177 0.188 0.955
Binary rand 6*8 0.663 0.955 0.747
Count the ones 0.409 0.885 0.612
Parking lot 0.865 0.233 0.351
Minimum distance 0.509 0.678 0.395
3D sphere 0.361 0.131 0.773
Squeeze 0.583 0.088 0.473
Overlapping sum 0.749 0.972 0.351
Run up 1 0.128 0.558 0.534
Run up 2 0.893 0.499 0.942
Run down 1 0.621 0.712 0.887
Run down 2 0.329 0.263 0.713
Craps number of throws 0.946 0.364 0.925
Craps number of wins 0.376 0.911 0.556

6. Conclusions

We present the cellular programming algorithm
with PSO and apply it to the problem of generating
random numbers. It would be safe to say that our CA
with PSO PRNG is slightly better than the best
available CA randomizers at this point if more
extensive suit of tests have been conducted.
In conclusion, it seems that our PSCA algorithm
can be used to quickly generate high-quality random
number sequences through taking suite of tests. It is
also easy to be implemented efficiently in hardware,
can be used in such application as parallel
computation, and also can be applied in VLSI built-in

7. Acknowledgments

This research was supported by the international
cooperation project of Ministry of Science and
Technology of PR China, grant No. CB 7-2-01, and by
“SEC E-Institute: Shanghai High Institutions Grid”

8. References

[1] S.K. Park, K.W. Miller: Random number generators:
Good ones are hard to find, Communications of the ACM
31(10) (1988) 1192–1201.

[2] P.D. Hortensius, R.D. McLeod, H.C. Card: Parallel
random number generation for VLSI systems using cellular
automata, IEEE Trans. Comput. 38(10) (1989) 1466–1473.

[3] D.E. Knuth: The Art of Computer Programming: Vol. 2,
Seminumerical Algorithms, Addison-Wesley, Reading, MA,
3rd ed., 1998.

[4] S. Wolfram: Random sequence generation by cellular
automata, Adv. Appl. Mathematics 7 (1986) 123–169.

[5] P.D. Hortensius, R.D. McLeod, W. Pries, D.M. Miller,
H.C. Card, Cellular automata-based pseudo-random number
generators for built-in self-test, IEEE Trans. Computer-Aided
Design 8(8) (1989) 842–859.

[6] D.R. Chowdhury, I.S. Gupta, P.P. Chaudhuri, A low-cost
high-capacity associative memory design using cellular
automata, IEEE Trans. Comput. 44(10) (1995) 1260–1264.

[7] M. Sipper, M. Tomassini, Generating parallel random
number generators by cellular programming, Intl. J. Modern
Phys. C7(2) (1996) 181–190.

[8] J. Kennedy and R. Eberhart, “Particle swarm
optimization.” Proc. IEEE International Conf. on Neural
Networks (Perth, Australia), IEEE Service
Center,Piscataway, NJ, 1995 (in press).