Statistical Testing of Additive Congruential Random Number...

1
RESEARCH POSTER PRESENTATION DESIGN © 2015 www.PosterPresentations.com ACORN generators represent an approach to generating uniformly distributed pseudo-random numbers which is straightforward to implement for arbitrarily large order k and modulus M=2 30t (integer t). They give long period sequences which can be proven theoretically to approximate to uniformity in up to k dimensions. INTRODUCTION ACORN GENERATOR THE TestU01 TEST SUITE The TestU01 package has been described by L’Ecuyer and Simard [7]. They considered the application of empirical tests of uniformity and randomness to sequences generated by a wide range of algorithms and developed a comprehensive set of empirical tests that were designed to detect undesirable characteristics in such sequences. L’Ecuyer and Simard present results of applying the TestU01 tests to a large number of different sequences, identifying generators that pass all of the tests (collectively called the BigCrush test battery), as well as identifying many generators (including some that are widely used) that have serious deficiencies in respect of certain specific tests. Results presented below for ACORN generators (which were not included among generators considered by L’Ecuyer and Simard) were obtained using the latest version 1.2.3 of TestU01. The BigCrush battery of tests calculates 180 different test statistics for each sequence that is tested, making use of some 2 38 pseudo-random numbers from each sequence. We follow L’Ecuyer and Simard in defining a “failure” to be a p-value outside the range [10 -10 , 1-10 -10 ] with a “suspect” value falling in one of the ranges [10 -10 , 10 -4 ] or [1-10 -4 , 1-10 -10 ]. RESULTS AND CONCLUSIONS ACKNOWLEDGEMENT AND CONTACT This work has been carried out with support from REAMC Limited. Email contact address: [email protected]. The ACORN pseudo-random number generator was first discovered in the mid-1980s and published in 1989 [1]. Let k be a finite, strictly positive integer. The k -th order Additive Congruential Random Number (ACORN) generator is defined from an integer modulus M, an integer seed Y 0 0 satisfying 0 < Y 0 0 < M and an arbitrary set of k integer initial values Y m 0 , m = 1, ..., k, each satisfying 0 Y m 0 M by the equations 0 = 0 −1 ≥1 (1) = −1 + −1 mod ≥ 1, = 1, … , (2) where [Y ] mod M means the remainder on dividing Y by M. Finally, the sequence of numbers Y k n can be normalised to the unit interval by dividing by M = / ≥1 (3) It turns out [2, 3, 4, 5] that the numbers X k n defined by equations (1) - (3) approximate to being uniformly distributed on the unit interval in up to k dimensions, provided a few simple constraints on the initial parameter values are satisfied modulus M needs to be a large integer (typically a prime power, with powers of 2 offering the most straightforward implementation); increasing modulus leads to improved statistical performance seed Y 0 0 and modulus chosen to be relatively prime (which means that their greatest common divisor is 1; for M a power of two this requires only that the seed is odd) initial values Y m 0 , m = 1, ..., k can be chosen arbitrarily The period length of resulting ACORN sequence can be shown to be a multiple of the modulus. REAMC Limited (Reservoir Engineering and Applied Mathematics Consultancy) Roy Wikramaratna Statistical Testing of Additive Congruential Random Number (ACORN) Generators REFERENCES [1] R.S. Wikramaratna, ACORN - A New Method for Generating Sequences of Uniformly Distributed Pseudo-random Numbers, J. Comput. Phys., 83, pp16-31, 1989. [2] R.S. Wikramaratna, Theoretical Background for the ACORN Random Number Generator, Report AEA-APS-0244, AEA Technology, Winfrith, Dorset, UK, 1992. [3] R.S. Wikramaratna, Pseudo-random Number Generation for Parallel Processing A Splitting Approach, SIAM News, 33 number 9, 2000. [4] R.S. Wikramaratna, The Additive Congruential Random Number Generator A Special Case of a Multiple Recursive Generator, J. Comput. and Appl. Mathematics, 261, pp371387, 2008. [doi: 10.1016/j.cam.2007.05.018]. [5] R.S. Wikramaratna, Theoretical and Empirical Convergence Results for Additive Congruential Random Number Generators, J. Comput. Appl. Math., 233, pp2302-2311, 2010. [doi: 10.1016/j.cam.2009.10.015]. [6] M. Matsumoto and T. Nishimura, Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator, ACM Trans. Model. Comput. Simul., 8, 3, 1998. [7] NAG, Numerical Algorithms Group (NAG) Fortran Library Manual, Mark 22, Numerical Algorithms Group Ltd, Oxford, UK, 2009. (www.nag.co.uk). [8] NAG, Numerical Algorithms Group (NAG) C Library Manual, Mark 23, Numerical Algorithms Group Ltd, Oxford, UK, 2012. (www.nag.co.uk). [9] C.V. Deutsch and A.G. Journel, GSLIB: Geostatistics Software Library and User’s Guide, Oxford University Press, 384 pp, 1998. [10] P. L'Ecuyer and R. Simard, TestU01: A C Library for Empirical Testing of Random Number Generators, ACM Transactions on Mathematical Software, 33, 4, Article 22, 2007. With M=2 120 and k≥9, ACORN generators passed all the tests for each of the 7 initialisations; since each choice of seed gives a different sequence this potentially gives more than 2 119 different sequences, each of length at least 2 120 , which might reasonably be expected to pass all of the tests in these test suites. With M=2 60 and k≥9, ACORN generators failed on average no more than two of the tests across the 7 initialisations tested; with M=2 90 (not shown in the figures) the performance was intermediate between the two cases shown with no failures and only occasional suspect values. This contrasts with corresponding results obtained for the widely-used Mersenne Twister MT19937 generator, which consistently failed on two of the tests in the BigCrush test suite. Further, we assert that an ACORN generator might also reasonably be expected to pass any more demanding tests for p-dimensional uniformity that may be required in the future, simply by choosing kp and modulus M=2 30t for sufficiently large t. Results shown are the average number of ‘failures’ (black bars) and ‘suspect values’ (grey bars) obtained with seven different seeds and initialisations (plotted on the x-axis) for ACORN generators with order 8≤k≤25 (plotted on the y-axis) and two values of modulus M=2 60 and M=2 120 . The only constraint on initialisation for the seven cases was that in each case the seed be a different odd integer less than the modulus. Results of testing show improvement of the overall results with increasing modulus. Corresponding results obtained for the Mersenne Twister MT19937 generator, are shown by the dotted line on the figures. IMPLEMENTATION The ACORN generator is straightforward to implement in a few tens of lines in high-level computer languages such as Fortran or C. The following example is in Fortran; with 32- bit integers (as shown) it allows a modulus up to 2 60 ; by using 64-bit integers it would allow modulus up to 2 120 with minimal modification to the source code. This is simplest and most easily understood implementation; significantly faster implementation is possible while still producing identical sequences for any specified initialisation. It can be extended to allow larger order by straightforward modifications to the common block. DOUBLE PRECISION FUNCTION ACORNJ(XDUM) C C ACORN GENERATOR C MODULUS =< 2^60, ORDER =< 12 C IMPLICIT DOUBLE PRECISION (A-H,O-Z) PARAMETER (MAXORD=12,MAXOP1=MAXORD+1) COMMON /IACO2/ KORDEJ 1 ,MAXJNT,IXV1(MAXOP1),IXV2(MAXOP1) DO 7 I=1,KORDEJ IXV1(I+1)=(IXV1(I+1)+IXV1(I)) IXV2(I+1)=(IXV2(I+1)+IXV2(I)) IF (IXV2(I+1).GE.MAXJNT) THEN IXV2(I+1)=IXV2(I+1)-MAXJNT IXV1(I+1)=IXV1(I+1)+1 ENDIF IF (IXV1(I+1).GE.MAXJNT) 1 IXV1(I+1)=IXV1(I+1)-MAXJNT 7 CONTINUE ACORNJ=(DBLE(IXV1(KORDEJ+1)) 1 +DBLE(IXV2(KORDEJ+1))/MAXJNT)/MAXJNT RETURN END After appropriate initialisation of the common block, each call to the function ACORNJ generates a single variate drawn from a uniform distribution on the unit interval. The ACORN generator has been used (alongside the widely-used Mersenne Twister algorithm [6] and a number of other algorithms that are based on linear congruential generators) by Numerical Algorithms Group Ltd since the Mark 22 release of their Fortran Numerical Software Libraries [7] and since the Mark 23 release of their C Numerical Software Libraries [8] as one of their standard base methods for generating uniformly distributed pseudo-random numbers. A version of the ACORN algorithm is also included in the GSLIB geostatistical software library, Deutsch and Journel [9]. M=2 60 M=2 120 PASCAL’S TRIANGLE AND ACORN SEQUENCES The ACORN generator turns out to have a close link with Pascal’s triangle. Numbering the diagonals from 0 through k, the terms in the k-th diagonal turn out to be a particular special case of a k-th order ACORN sequence. As a result we can show that the sequence formed by taking the terms in the k-th diagonal modulo M (where M is a large power of 2) and dividing by M is a periodic sequence whose period is a multiple of M a sequence which approximates to uniform distributed in k dimensions. This is one example of some fascinating mathematical properties that can be demonstrated or proved for the ACORN sequences. Other examples are included in the references [1, 2, 3, 4, 5]. Poster presented at the meeting on ‘Numerical algorithms for high-performance computational science’, 8 – 9 April 2019, The Royal Society, London.

Transcript of Statistical Testing of Additive Congruential Random Number...

Page 1: Statistical Testing of Additive Congruential Random Number ...acorn.wikramaratna.org/assets/ACORN_TestingWith... · This PowerPoint 2007 template produces an A0 presentation poster.

(—THIS SIDEBAR DOES NOT PRINT—)

DES IGN GUIDE

This PowerPoint 2007 template produces an A0

presentation poster. You can use it to create your

research poster and save valuable time placing titles,

subtitles, text, and graphics.

We provide a series of online tutorials that will guide

you through the poster design process and answer your

poster production questions. To view our template

tutorials, go online to PosterPresentations.com and

click on HELP DESK.

When you are ready to print your poster, go online to

PosterPresentations.com

Need assistance? Call us at 1.510.649.3001

QUICK START

Zoom in and out As you work on your poster zoom in and out to

the level that is more comfortable to you. Go

to VIEW > ZOOM.

Title, Authors, and Affiliations Start designing your poster by adding the title, the names of

the authors, and the affiliated institutions. You can type or

paste text into the provided boxes. The template will

automatically adjust the size of your text to fit the title box.

You can manually override this feature and change the size of

your text.

TIP: The font size of your title should be bigger than your

name(s) and institution name(s).

Adding Logos / Seals Most often, logos are added on each side of the title. You can

insert a logo by dragging and dropping it from your desktop,

copy and paste or by going to INSERT > PICTURES. Logos

taken from web sites are likely to be low quality when

printed. Zoom it at 100% to see what the logo will look like

on the final poster and make any necessary adjustments.

TIP: See if your school’s logo is available on our free poster

templates page.

Photographs / Graphics You can add images by dragging and dropping from your

desktop, copy and paste, or by going to INSERT > PICTURES.

Resize images proportionally by holding down the SHIFT key

and dragging one of the corner handles. For a professional-

looking poster, do not distort your images by enlarging them

disproportionally.

Image Quality Check Zoom in and look at your images at 100% magnification. If

they look good they will print well.

ORIGINAL DISTORTED Corner handles

Go

od

pri

nti

ng

qu

alit

y

Bad

pri

nti

ng

qu

alit

y

QUICK START (cont. )

How to change the template color theme You can easily change the color theme of your poster by going

to the DESIGN menu, click on COLORS, and choose the color

theme of your choice. You can also create your own color

theme.

You can also manually change the color of your background by

going to VIEW > SLIDE MASTER. After you finish working on

the master be sure to go to VIEW > NORMAL to continue

working on your poster.

How to add Text The template comes with a number of pre-

formatted placeholders for headers and

text blocks. You can add more blocks by

copying and pasting the existing ones or by

adding a text box from the HOME menu.

Text size Adjust the size of your text based on how much content you

have to present.

The default template text offers a good starting point. Follow

the conference requirements.

How to add Tables To add a table from scratch go to the INSERT menu

and click on TABLE. A drop-down box will help you

select rows and columns.

You can also copy and a paste a table from Word or another

PowerPoint document. A pasted table may need to be re-

formatted by RIGHT-CLICK > FORMAT SHAPE, TEXT BOX,

Margins.

Graphs / Charts You can simply copy and paste charts and graphs from Excel

or Word. Some reformatting may be required depending on

how the original document has been created.

How to change the column configuration RIGHT-CLICK on the poster background and select LAYOUT to

see the column options available for this template. The

poster columns can also be customized on the Master. VIEW >

MASTER.

How to remove the info bars If you are working in PowerPoint for Windows and have

finished your poster, save as PDF and the bars will not be

included. You can also delete them by going to VIEW >

MASTER. On the Mac adjust the Page-Setup to match the

Page-Setup in PowerPoint before you create a PDF. You can

also delete them from the Slide Master.

Save your work Save your template as a PowerPoint document. For printing,

save as PowerPoint or “Print-quality” PDF.

Print your poster When you are ready to have your poster printed go online to

PosterPresentations.com and click on the “Order Your Poster”

button. Choose the poster type the best suits your needs and

submit your order. If you submit a PowerPoint document you

will be receiving a PDF proof for your approval prior to

printing. If your order is placed and paid for before noon,

Pacific, Monday through Friday, your order will ship out that

same day. Next day, Second day, Third day, and Free Ground

services are offered. Go to PosterPresentations.com for more

information.

Student discounts are available on our Facebook page.

Go to PosterPresentations.com and click on the FB icon.

© 2015 PosterPresentations.com 2117 Fourth Street , Unit C Berkeley CA 94710

[email protected] RESEARCH POSTER PRESENTATION DESIGN © 2015

www.PosterPresentations.com

ACORN generators represent an approach to generating uniformly distributed pseudo-random

numbers which is straightforward to implement for arbitrarily large order k and modulus M=230t

(integer t). They give long period sequences which can be proven theoretically to approximate to

uniformity in up to k dimensions.

INTRODUCTION

ACORN GENERATOR

THE TestU01 TEST SUITE

The TestU01 package has been described by L’Ecuyer and Simard [7]. They considered the

application of empirical tests of uniformity and randomness to sequences generated by a wide

range of algorithms and developed a comprehensive set of empirical tests that were designed to

detect undesirable characteristics in such sequences. L’Ecuyer and Simard present results of

applying the TestU01 tests to a large number of different sequences, identifying generators that

pass all of the tests (collectively called the BigCrush test battery), as well as identifying many

generators (including some that are widely used) that have serious deficiencies in respect of

certain specific tests.

Results presented below for ACORN generators (which were not included among generators

considered by L’Ecuyer and Simard) were obtained using the latest version 1.2.3 of TestU01.

The BigCrush battery of tests calculates 180 different test statistics for each sequence that is

tested, making use of some 238 pseudo-random numbers from each sequence. We follow

L’Ecuyer and Simard in defining a “failure” to be a p-value outside the range [10-10, 1-10-10] with

a “suspect” value falling in one of the ranges [10-10, 10-4] or [1-10-4, 1-10-10].

RESULTS AND CONCLUSIONS

ACKNOWLEDGEMENT AND CONTACT

This work has been carried out with support from REAMC Limited.

Email contact address: [email protected].

The ACORN pseudo-random number generator was first discovered in the mid-1980s and

published in 1989 [1].

Let k be a finite, strictly positive integer. The k -th order Additive Congruential Random Number

(ACORN) generator is defined from an integer modulus M, an integer seed Y 00 satisfying

0 < Y 00 < M and an arbitrary set of k integer initial values Y m0, m = 1, ..., k, each satisfying

0 Y m0 M by the equations

𝑌0𝑛 = 𝑌0

𝑛−1 𝑛 ≥ 1 (1)

𝑌𝑚𝑛 = 𝑌𝑚−1

𝑛 + 𝑌𝑚𝑛−1 mod𝑀 𝑛 ≥ 1, 𝑚 = 1, … , 𝑘 (2)

where [Y ]mod M means the remainder on dividing Y by M.

Finally, the sequence of numbers Y kn can be normalised to the unit interval by dividing by M

𝑋𝑘𝑛 = 𝑌𝑘

𝑛/𝑀 𝑛 ≥ 1 (3)

It turns out [2, 3, 4, 5] that the numbers X kn defined by equations (1) - (3) approximate to being

uniformly distributed on the unit interval in up to k dimensions, provided a few simple

constraints on the initial parameter values are satisfied

• modulus M needs to be a large integer (typically a prime power, with powers of 2 offering the

most straightforward implementation); increasing modulus leads to improved statistical

performance

• seed Y 00 and modulus chosen to be relatively prime (which means that their greatest common

divisor is 1; for M a power of two this requires only that the seed is odd)

• initial values Y m0, m = 1, ..., k can be chosen arbitrarily

The period length of resulting ACORN sequence can be shown to be a multiple of the modulus.

REAMC Limited (Reservoir Engineering and Applied Mathematics Consultancy)

Roy Wikramaratna

Statistical Testing of Additive Congruential Random Number (ACORN) Generators

REFERENCES

[1] R.S. Wikramaratna, ACORN - A New Method for Generating Sequences of Uniformly

Distributed Pseudo-random Numbers, J. Comput. Phys., 83, pp16-31, 1989.

[2] R.S. Wikramaratna, Theoretical Background for the ACORN Random Number Generator,

Report AEA-APS-0244, AEA Technology, Winfrith, Dorset, UK, 1992.

[3] R.S. Wikramaratna, Pseudo-random Number Generation for Parallel Processing – A Splitting

Approach, SIAM News, 33 number 9, 2000.

[4] R.S. Wikramaratna, The Additive Congruential Random Number Generator – A Special Case

of a Multiple Recursive Generator, J. Comput. and Appl. Mathematics, 261, pp371–387, 2008.

[doi: 10.1016/j.cam.2007.05.018].

[5] R.S. Wikramaratna, Theoretical and Empirical Convergence Results for Additive

Congruential Random Number Generators, J. Comput. Appl. Math., 233, pp2302-2311, 2010.

[doi: 10.1016/j.cam.2009.10.015].

[6] M. Matsumoto and T. Nishimura, Mersenne twister: a 623-dimensionally equidistributed

uniform pseudo-random number generator, ACM Trans. Model. Comput. Simul., 8, 3, 1998.

[7] NAG, Numerical Algorithms Group (NAG) Fortran Library Manual, Mark 22, Numerical

Algorithms Group Ltd, Oxford, UK, 2009. (www.nag.co.uk).

[8] NAG, Numerical Algorithms Group (NAG) C Library Manual, Mark 23, Numerical

Algorithms Group Ltd, Oxford, UK, 2012. (www.nag.co.uk).

[9] C.V. Deutsch and A.G. Journel, GSLIB: Geostatistics Software Library and User’s Guide,

Oxford University Press, 384 pp, 1998.

[10] P. L'Ecuyer and R. Simard, TestU01: A C Library for Empirical Testing of Random Number

Generators, ACM Transactions on Mathematical Software, 33, 4, Article 22, 2007.

With M=2120 and k≥9, ACORN generators passed all the tests for each of the 7 initialisations;

since each choice of seed gives a different sequence this potentially gives more than 2119

different sequences, each of length at least 2120, which might reasonably be expected to pass all

of the tests in these test suites.

With M=260 and k≥9, ACORN generators failed on average no more than two of the tests across

the 7 initialisations tested; with M=290 (not shown in the figures) the performance was

intermediate between the two cases shown with no failures and only occasional suspect values.

This contrasts with corresponding results obtained for the widely-used Mersenne Twister

MT19937 generator, which consistently failed on two of the tests in the BigCrush test suite.

Further, we assert that an ACORN generator might also reasonably be expected to pass any

more demanding tests for p-dimensional uniformity that may be required in the future, simply by

choosing k≥p and modulus M=230t for sufficiently large t.

Results shown are the average number of

‘failures’ (black bars) and ‘suspect values’

(grey bars) obtained with seven different seeds

and initialisations (plotted on the x-axis) for

ACORN generators with order 8≤k≤25

(plotted on the y-axis) and two values of

modulus M=260 and M=2120. The only

constraint on initialisation for the seven cases

was that in each case the seed be a different

odd integer less than the modulus. Results of

testing show improvement of the overall

results with increasing modulus.

Corresponding results obtained for the

Mersenne Twister MT19937 generator, are

shown by the dotted line on the figures. IMPLEMENTATION

The ACORN generator is straightforward to

implement in a few tens of lines in high-level

computer languages such as Fortran or C.

The following example is in Fortran; with 32-

bit integers (as shown) it allows a modulus up

to 260; by using 64-bit integers it would allow

modulus up to 2120 with minimal modification

to the source code.

This is simplest and most easily understood

implementation; significantly faster

implementation is possible while still

producing identical sequences for any

specified initialisation. It can be extended to

allow larger order by straightforward

modifications to the common block.

DOUBLE PRECISION FUNCTION ACORNJ(XDUM)

C

C ACORN GENERATOR

C MODULUS =< 2^60, ORDER =< 12

C

IMPLICIT DOUBLE PRECISION (A-H,O-Z)

PARAMETER (MAXORD=12,MAXOP1=MAXORD+1)

COMMON /IACO2/ KORDEJ

1 ,MAXJNT,IXV1(MAXOP1),IXV2(MAXOP1)

DO 7 I=1,KORDEJ

IXV1(I+1)=(IXV1(I+1)+IXV1(I))

IXV2(I+1)=(IXV2(I+1)+IXV2(I))

IF (IXV2(I+1).GE.MAXJNT) THEN

IXV2(I+1)=IXV2(I+1)-MAXJNT

IXV1(I+1)=IXV1(I+1)+1

ENDIF

IF (IXV1(I+1).GE.MAXJNT)

1 IXV1(I+1)=IXV1(I+1)-MAXJNT

7 CONTINUE

ACORNJ=(DBLE(IXV1(KORDEJ+1))

1 +DBLE(IXV2(KORDEJ+1))/MAXJNT)/MAXJNT

RETURN

END

After appropriate initialisation of the common block, each call to the function ACORNJ

generates a single variate drawn from a uniform distribution on the unit interval.

The ACORN generator has been used (alongside the widely-used Mersenne Twister algorithm

[6] and a number of other algorithms that are based on linear congruential generators) by

Numerical Algorithms Group Ltd since the Mark 22 release of their Fortran Numerical Software

Libraries [7] and since the Mark 23 release of their C Numerical Software Libraries [8] as one of

their standard base methods for generating uniformly distributed pseudo-random numbers.

A version of the ACORN algorithm is also included in the GSLIB geostatistical software library,

Deutsch and Journel [9].

M=260

M=2120

PASCAL’S TRIANGLE AND ACORN SEQUENCES

The ACORN generator turns out to have a close link with Pascal’s triangle. Numbering the

diagonals from 0 through k, the terms in the k-th diagonal turn out to be a particular special case

of a k-th order ACORN sequence.

As a result we can show that the sequence

formed by taking the terms in the k-th

diagonal modulo M (where M is a large

power of 2) and dividing by M is

• a periodic sequence whose period is a

multiple of M

• a sequence which approximates to

uniform distributed in k dimensions.

This is one example of some fascinating

mathematical properties that can be

demonstrated or proved for the ACORN

sequences. Other examples are included in

the references [1, 2, 3, 4, 5].

Poster presented at the meeting on ‘Numerical algorithms for high-performance computational science’, 8 – 9 April 2019, The Royal Society, London.