Proposing √11 and √29 as Random Number Generators

advertisement
IRACST - International Journal of Advanced Computing, Engineering and Application (IJACEA), ISSN: 2319-281X,
Vol. 1, No.3, December 2012
Proposing √11 and √29 as Random Number Generators
1
Jayantika Pal and 2*Soubhik Chakraborty and 3Namrata Bagree
Department of Applied Mathematics, BIT Mesra, Ranchi-835215, India
Deptt. of Statistics, University of Warwick, CV4 7ES, Coventry, West Midlands, UK
*Email of the corresponding author: soubhikc@yahoo.co.in
Abstract: Like numbers generated from
an arbitrary seed in a Pseudo-random
Number Generator (PRNG) may not be
random, a substring taken from an
arbitrary position in the decimal
expansion of an irrational number may
not be random. But while the PRNG
generally have a cycle, the decimal
expansion in any irrational number is
non-repeating and non-terminating.
Using Wolfram’s Mathematica software
we generated one lakh decimal digits of
the irrational numbers √11, √29 and π
and kept in separate text files. By
programming done in Dev C software,
we obtained the percentage of times a
substring of a given length passes the
run test for randomness if taken from
arbitrary positions. Both √11 and √29
seem to be performing well in
comparison to π as a reference point.
There being a controversy over the
randomness of π in the recent past, we
propose √11 and √29 as alternative
random number generators.
Key Words: (Pseudo) randomness,
cycle, run test, irrational number,
decimal expansion, continued fraction
expansion
1. INTRODUCTION
Realizations of random processes are the
raw materials of classical statistical
inferences.
Most applications in statistical methods
based research require a “random
sample” or a “random assignment” [1].
A random number generator (RNG)) is a
computational or physical device
designed to generate a sequence of
numbers or symbols that lack any
pattern,
i.e.
appear
random
http://en.wikipedia.org/wiki/Random.
Random number generators have
applications in gambling, computer
simulation, cryptography, completely
randomized design, development of
statistical methods & theory and areas
where producing an unpredictable result
is desirable [2]. By the law of statistical
regularity, only a random sample
represents a population.
It is well known fact that numbers
generated by an arbitrarily selected seed
for a Pseudo-random Number Generator
(PRNG) may not be statistically random
[2]. Matsumoto et al.
[3] painstakingly experimented with 58
generators and discovered as many as
40 to be
defective. Further investigation
revealed that the unwanted pattern is
caused by the
wrong
choice
of
initialization
rather
93
IRACST - International Journal of Advanced Computing, Engineering and Application (IJACEA), ISSN: 2319-281X,
Vol. 1, No.3, December 2012
than
recursion. An
interesting
aspect is that PRNG generally have a
cycle, i.e., it generates the same
sequence,
whereas
the
decimal
expansion in any irrational number is
non-repeating and non-terminating. A
literature survey on pseudo random
number generators, testing for their
randomness etc is carried out [4-16].
A run is a sequence of letters of one kind
preceded and/or followed by letters of
another kind. A sequence is statistically
random if the number of runs is neither
too large nor too small. In this paper, the
evaluation for randomness of a substring
of different length, at arbitrary positions,
of the decimal expansion of some
irrational numbers from at least 1 lakh
digits is reported. This study is important
because, just as numbers generated from
an arbitrary seed may not be random, so
a substring taken from an arbitrary
position may not be random. For this we
carried out the percentage of times a
substring of a given length passes the
run test for randomness if taken from
arbitrary positions 100 times.
Wolfram’s Mathematica software [17] is
used to generate the one lakh decimal
digits of the irrational numbers. The
programming of the algorithm for the
run test is done using Dev C [18]
software. Evaluation of randomness for
the irrational numbers, π, √11, √29 and
their results are reported in this work.
94
IRACST - International Journal of Advanced Computing, Engineering and Application (IJACEA), ISSN: 2319-281X,
Vol. 1, No.3, December 2012
TEST OF RANDOMNESS OF DECIMAL DIGITS OF ANY IRRATIONAL
NUMBER FOR FIXED LENGTH n WHICH SRARTS FROM AN ARBITARY
POSITION s. The algorithm used here is similar to that used in our previous
work [6] on π.
Algorithm:
Step 1: Create a text file say ra29.txt for an irrational no square root of 29. Step
2: Set MAX=100000.
Step 3: Input n. Step 4:
z=U (0, 1)
s=INT [z*(MAX-n)] + 1
when n = MAX, s=1 otherwise is a random number between 1 and MAX-n Step 5:
Create an array arrs (convert characters to numbers) of n elements starting
from s
th
position of the text file ra29.txt.
Step 6: Create an array arrws by copying all the elements of arrs. Step
7: Find the median by the following steps:[a] Sort the array arrs
[b] If n is odd, median = (n/2)
th
term
[c] If n is even, median=mean of (n/2)
th
and (n/2+1)
th
term Step
8: From the first digit to the unsorted array arrws,
[a] Write ‘A’ if the digit is less than the median , or
95
IRACST - International Journal of Advanced Computing, Engineering and Application (IJACEA), ISSN: 2319-281X,
Vol. 1, No.3, December 2012
[b] Write ‘B’ if more, or
[c] If equal, draw a uniform number p between (0 to 1),if p>0.5 then write
‘B’ otherwise ‘A’
Step 9: Store all characters in a string variable txtstr, which is obtained from Step 8
Step 10: Initialize a new character variable temp with the first character of txtstr and
set c=1
Step 11: From second character on wards , examine with temp, if unequal
c=c+1 and temp= corresponding character. If equal examine the next
character. Find value of c gives the number of runs in txtstr.
Step 12: c is asymptotically normal with mean E(c) = (n+2)/2
Variance Var(c) = n(n-2)/4(n-1)
1/2
Calculate U = {c-E(c)}/{Var(c)}
Where U is N (0,1) for large n
Step 13: If |U |<1.96,subsequence may be taken as random at 5% level of significance.
Step 14: Repeat steps 4 to 13 a large number of times for every n chosen.
The above algorithm for the run test of an irrational number is coded in Dev C software.
The algorithm has been applied to the following irrational numbers π(pi) , √11, √29. The
results of their passing of randomness test using a seed of arbitrary length (n) in the
chosen length of total 1 lakh digits is tabulated in the following table.
96
IRACST - International Journal of Advanced Computing, Engineering
and Application (IJACEA), ISSN: 2319-281X,
Vol. 1, No.3, December 2012
Length
(n)
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
π(pi)
96
99
92
98
92
95
96
96
96
94
95
93
97
92
93
95
98
95
92
94
96
97
96
98
98
92
98
95
95
97
92
93
96
98
93
98
93
98
Percentage of pass
√11
97
99
94
97
95
95
97
92
97
96
98
93
93
92
98
95
98
99
99
95
93
92
94
94
97
98
97
94
93
99
93
97
96
97
93
97
95
96
√29
93
98
97
96
95
95
93
98
96
96
97
93
98
95
96
96
93
96
94
94
98
98
96
98
96
94
95
96
93
93
97
98
96
95
92
96
94
96
97
IRACST - International Journal of Advanced Computing, Engineering and Application (IJACEA), ISSN: 2319-281X,
Vol. 1, No.3, December 2012
390
400
410
420
96
98
96
96
94
94
97
100
96
96
98
96
430
97
96
98
440
450
460
470
480
490
500
97
95
95
94
93
93
91
97
94
96
99
96
98
93
96
91
99
98
98
95
98
Remark: The decimal expansion of an irrational number can be obtained using
continued fraction expansion. See [16].
Conclusion:
Research has been
continuing on the randomness of the
decimal expansion of irrational number
that are used to distinguished good from
not so good random number generators
when applied to the decimal digits of
any irrational number. But the works
talk of randomness on the whole. If a
sequence is random on the whole, it does
not follow that different subsets taken
from arbitrary positions will also be
random as overall independence does
not imply mutual independence. So we
made the resent study in which random
substrings of arbitrary lengths have been
extracted from arbitrary positions a large
number of times and each sample is
tested for randomness. There are so
many
controversies
about
the
randomness of pi like the recent claim
that “pi is less random than we thought”
[19]. George Marsaglia [5] has
independently refuted the claim, but he
established the randomness on the whole
for the first 960 million digits of pi.
These research findings confirm that pi
as well as √11 and √29 are good random
number generator since (i) they don’t
generate a cycle being irrational in
nature and (ii) arbitrary substrings of
different lengths taken from arbitrary
positions are also random barring a few
non-random substrings, that is to say, the
pass % is fairly high in all the three. The
result (ii) is very important as the
arbitrary positions actually correspond to
seed in other models of pseudorandom
number generators in the computer. In
those models, numbers generated from
an arbitrarily selected seed may not be
random [3].
Remark: The most popular pseudo
random number generator is Mersenne
Twister 19937. See [20]. for more on
this. A sequence, strictly speaking, is
truly random if the length of the shortest
program that outputs the sequence (this
is called the Kolmogorov complexity of
the sequence) equals the length of the
sequence. See [21] for an illustrative
example.
98
IRACST - International Journal of Advanced Computing, Engineering and Application (IJACEA), ISSN: 2319-281X,
Vol. 1, No.3, December 2012
References
1.
W. J.Kennedy and J.E.Gentle, Statistical Computing, Marcel Dekker Inc.,
New York, Vol. 33, Chap 6, 1980
2.
Wikipedia (http://en.wikipedia.org/wiki/Random_number_generation)
3.
Matsumoto, M., Wada, I. ,Kuranmoto,A. and Ashihara,H., Common defects in
Initialization of pseudorandom number generators, ACM Transactions on
modeling and Computer Simulation, 17(4), article 15, 2007
4.
5.
S.Chakraborty , Review of the research paper in ref. [3] published in Computing
reviews, Dec 23, 2007 (www.computingreviews.com)
G.Marsaglia, Refutation of claims such as “Pi is less random we thought”
Interstat,(12/24/2007)
http://interstat.statjournals.net/YEAR/2006/abstracts/0601001.php?Name=601001
6.
S. K. Sourabh, S. Chakraborty and B. K. Das., Are subsequence of decimal digits
nd
of pi random? Anale. seria informatica. Vol.VII, 2
7.
Mario Rütti
fasc, 2009
A Random Number Generator Test Suite for the C++ Standard
(10/3/2004)
8.
www.randomnumbers.info/content/Random.htm
9.
mathworld.wolfram.com › ... › Random Numbers
10.
stattrek.com/statistics/random-number-generator.aspx
11.
searchcio-midmarket.techtarget.com/definition/random-numbers
12.
www.graphpad.com/quickcalcs/randomn1.cfm
13.
G Marsaglia, The Marsaglia Random Number CDROM, with The Diehard Battery
of Tests of Randomness, produced at Florida State University under a grant
from The National Science Foundation, available at
http://www.cs.hku.hk/_diehard/ or an earlier version
at http://www.stat.fsu.edu/pub/diehard, 1985
14.
G. Marsaglia , On the Randomness of Pi and Other Decimal Expansions,
Florida State University. http://interstat.statjournals.net, October, 2005
99
IRACST - International Journal of Advanced Computing, Engineering and Application (IJACEA), ISSN:
2319-281X,
Vol. 1, No.3, December 2012
15.
www.random.org, What's this fuss about true randomness?
16.
S.G.Telang, Number Theory, Tata McGraw-Hill Publishing company
limited, New Delhi, Chap 4, 1996
17.
www.wolfram.com/mathematica
18.
www.bloodshed.net/devcpp.html
19.
Shu-Ju Tu and Ephraim Fischbach, A study on the randomness of π(pi),
International journal of Modern Physics C,16,No.2,281-294,2005
20.
21.
www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
S. Chakraborty, On Why and What of Randomness, DataCritica: International
Journal of Critical Statistics, Vol. 3. No. 2, 2010, 1-13
100
Download