Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
24 views20 pages

Random Numbers

The document discusses the concept of random numbers and their significance in Monte Carlo methods and stochastic systems. It explains the properties of random numbers, the generation of pseudo random numbers, and various methods for generating them, including the mid-square method. Additionally, it highlights the importance of validating random number generators to ensure their effectiveness in simulations.

Uploaded by

cadetbro23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views20 pages

Random Numbers

The document discusses the concept of random numbers and their significance in Monte Carlo methods and stochastic systems. It explains the properties of random numbers, the generation of pseudo random numbers, and various methods for generating them, including the mid-square method. Additionally, it highlights the importance of validating random number generators to ensure their effectiveness in simulations.

Uploaded by

cadetbro23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

- ' l ' •

' '
I '

'RANVOM · NUM'Bf'RS
• I
I
• f

4.1 . Random Numbers 1 t' ~ ;

The earlier chapters h~~e , . . ·


very ~!early illustrated tha .
ingredient in the applica t ran~om n~mbers a~e a ne
tion of Monte Carlo meth ce
randomness. There are a od or simulation of situa
large number of systems, ~ tio ns i
called stgchastic_systems. !~ S h! '!~..J~!ays a P~.!l T~
Even for the solution of pr ese sy
numbers are required for sim oblems, which are determi
ulation. nistic
, _ What are random nu
mbers? These numb~rs are '
rando~ ~a~iab~e betwe~~ sa~ples d~awn from a u~
some specifie~ _intei;vals, an ifo nnty d'
Properties of Random Nu d they have equal probab
ility of
mbers : .. . . .i , :
A sequence of random nu
mbers has two important sta
tistical properties.
(. - uniformity, and 1
' '
\ - independence.
f(x)
Each random number is an
independent sample
drawn from a continuous un
ifonri distribution between
an interval O to 1. The pr
obability density function
(pdt) is shown in Fig.·4.1 .
and is given by, 1

1, 0S xS l
f(x ) = {0, otherwise
The expected value of each r,

given by random number R is . , .


. , . . , 1
. . · ·
I . . I t

1
xdx =- \ = _
X2 I
E (R) =
J
0 2 0 2
0
1
Fig. 4.1
l
and variance is given by V(

R) = Jx 2dx-[E (R)]2 =~ \-(.!.]2 = _!__.!_ = J_
If the mterval between O 0 3. 0 2 3 4 12
• the probability of observ and 1 is divided .
ing a . mto ~~uaj_eaTt_!.or cla
values drawn. va1ue m a sp eciti d . sses of equal len
. .
• if a total of m observati
e interval 1s independent of the
ons are taken th
interval is min, for uniform
distributio' en the expecte
n. d number of observati
4.2 Random Number
Table
Let us conduct a simple expe
identical chips of paper an riment to d
d write down the ;~ ~"stra th
them well, and take out on te e generation of random
e chip. It is a rando:1: O, 2 nwnbe
l, , 3, ..... , 9 on them. Pu
:'b er between Oand 9 bo t them in
th inelusi•
flandom Numbers • 57

experiment, each time returning the chip to the box and J ," t, I I • l•
rnixing them well. Instead of 10 pieces of paper we can
have say 50 with digits 0, 1, 2, 3, •.. ... , 9 repeated 5
times. Each time, draw 5 pie·ces and_note down their ,,
numbers. Thus each time 5 random digits are obtained. ,·
These can be listed in the form of a table similar to .
Appendix Table A-1. Such a table is called a rand~m
number table. The most comprehensive of alt published
tables of rand?m numbers is due to ~ND Corporation, '·
which con.tams one milli,on random digits. These
numbers_w~re generated by using a special roulette, ·,.
which incorpor~ted electric devices, A simple roulette .
wheel, shown in Fig.'4.2, comprises of a' disc divided '' '·
1
into 10 equal sectors numbered from Oto 9.' The i .__ -------------

rotating disc is abruptly stopped and the number -·: ',,. :-


against the pointer is noted dowri as a 'random digit. . . I • :,,

• ' : I'. f •

4.3 Pseudo Random Number~ ~-·'_·.;· ;, :: . · ..· "'·. • . '· ··;·:. ,, . ' .. :· - ~ ' ··, .
• •• • t_ • •-l• . .·.\ , l ' · ' r .. ' ' '. · / .~ ' 11., ... fr .. 1, i •f• ... • .• ;: .. •·;_ ·,~1, :.~ '. l • . · . , ...

The ' pseudo' means false. But here word 'pseudo\ implies that the r.andom numbers are .
generated by ~sing some known arithmetic operation. Sinc·e; the a;ith~etic· o·perati~-n i~ known and
the sequence .of random numbers ,can be repeat~dly obtainec( the numb.ers .cannot b;· ~ailed truly
random. However, the pse~do ran9om~numbers' generated by -~any c9mputer routines, ·v~ry closely
fultillthe ·requirementofdesired randomness. · ·-•'., · '.,
I t l I; • ~ ;~ ' -• ,~ l ( • f ) • ' • •

If the method of random number generation that is the random number generator is defective,
the generated pseudo random numbers may ha~e following' departures from' ideal randomness .
• The· gener~ted n~~bers ~ i y not tie uniformly ,d.istrlb~t~·d.' . ' : " .. '
.. f ( 'I'.
• The generated numbers may not be continuous.
• The mean of the generated numbers may be too high or too low.
• The variance may be too high or too low.
• There may be cyclic patterns in the generated numbers, like; . , . .'
(a) Auto correction between numbers.
(b) A group of numbers continuously above the mean, followed by a group continuously
below the mean. · - -- -· - ,
Thus, before employing a pseudo random number generator, it'Should be properly validated,
by testing the generated random numbers for randomness. The random number tests commonly used
are explained in Sections 4.1 Oto 4.14. · ·1
4.4 Generation of Random Numbers ' ~- . ;, ·, \ - i

In the examples discussed so far, random number table was used to obtai_n t~e random
observations. In computer simulation, where a very large number of random numbers is generally
required, the random numbers can be obtained by the following methods. , , . . .: . ·-
(a) Random numbers may be drawn from the random number tables stored in the memory of
the computer. This process, ·however, is neither practicable nor economical. It is a very slow .
.v process, and the numbers occupy considerable space of computer memory. Above all, in
real system sirpulation, a·single run may require many times more random numbers than
available in tables. . -·. •.·• , ,. \ , _ .
System Simulation
58

(b) An electronic device may be constructed as part of the digita


l computer to generate truly
. . , · .,,. .
random numbers. This, however, is considered very expensive. .
operation. These methods
(c) Pseudo Random Numbers be generated by using some arithmetic
number, the second
f!IOSt commonly specify a procedure, where starting with an initial
er of"recursive
numb er is gener ated and from that a third numb er and so on~ A numb
descri bed in the
proce dures (algori~hms) are given in literat ure, some of which are
· ~ ··
following sections. ,
,~ I ; • {~ ," • '!

4.5 Mid-square Random Number Generator ; ~ ' ,


' j •

numbeJs. It was used in '


t

This is one of the earliest methods used for generating pseudo random
ar weapons. The method
1950s, when the principle use of simulation was in designing thermonucle
n digits in_the middle a~ the
comprises of starting with an n-digit number, squaring it and taking the
start with a 4-digit n~mber.
next number, which is then squared to obtain the n~xt number. Say, we
t~e two low order digits and
The square will be of 7 or 8 digits. From the squared number chop off
one or two high order digits, to obtain a 4-digit number in the middle.
removing two low ord~
Let the seed ~u~be r be 5673, when squared we. get 32182929: After
Its square is 3345241. After
digits and two high order digits; we get the next random number 1829.
m number. Some random·
removing two low order and one high order digit, we get 3452 as ra~do 1
• •
numbers obtained from the seed 5673 are; · ·. 1- · .-.: ·• · •

5673 • ' . . 1829 • 3452 . • I 9] 63 . 9605 2560 - 5536


.. 8867 ·, 6236 ,. _'r; · ·,_ 8876 I~ 7833 3558 ,r 6593
6472
6724 . 2)2) 4986
4676 .·, - ' 8649 ' ·,,r 8052 l.' . . ''3347
' ' .1665, 7722
8601 9772 . 4919 1965 8612
5892 .. , 7156 .... . 2()83; . . ,, 3388_', ·,• 4785 8962
6292 •r , /I • _ • _ • ~ ~
,.. 1
,.

numbe rs by the mid-sq uare algorithm


A computer program in C language for gene.ra:ting random
is given below : · · ' ·· · · ·· ! • • • · " • • • - · •
' 1
::• ·: : • I "t;: • ,; t \ ·' • • •1

I • •••

#incl ude< stdio .h>


#incl ude< stdli b.h>
#incl ude< math .h>
,, r!
main ()
{ . ..
ers•/
/* Mid- Squa re Metho d of Gene ratin g 4-di git Random Numb
/*, seed is the start ing · 4-dig it rando m numb er, .,- ·
n is the numb er of random numb ers to be · gene rated
xis the rando m num ber•/ I I

long int i,s,x ,y,z, nd,s eed;


int · n; · C-
. 'seed= · 6185 ;
prin tf("\ n Number of- random numb ers to be gene rated n=•);
scan f("td •,&n ); , ·· ·. · I .
..

for Ci• l; ic.n; ++i) { '·


y a seed*.seed / 100.;
Z• y/100 00.;
dOl'l'I Numbers 59
~•" x=int( (y/10000.- z)*lOOOO .);
seed=X;
printf(" %4ld ~.X);
} ' I
}

Asequence of 30 numbers generated with a·s~-~~ of 6785 is ·~lven below ; •


1303 6978 6924 9416 ., 6609 · 6788 ·. .0768 : 5898 ' 7863
0361
· 8267 3431 .· 771 6 5366· 7938 . 0118 · 0139 0193 8372 1385
.. 9126 2837 ' •• 484 ' 2342 4848 ••. 5031 :3108 6595 4940 • 4036 I

The_ pr?b~em wit_h th e mid-square ~seudo random ~umber generator is _that t~~ s~quence ~f
numbers 1s limited. With very few exceptions mid-square either degenerates to zero, converge on a
constant (the s~ed 25 00 never departs from that value) or cycle fore·ver t.hrough a short loop, (the seed
10 th e cycle 2 1_00, 4100, 8100, 6100, .:.:.). Long sequences comprising of one_lac or
7777 ends up
more numbers can be obtained by using longer seed numbers. Three degenerate mid-square
sequences are given below. ., · ·. · ·,·. · : , . · . . , . ;_ . . ·. · . · ,
Seed 2061 gives; ·
; '·i 2061 2477. 1355' . 8360 , 8896 ·: 1388 · · 9265 · 8402 '
5936 2360 5696 4444 7491 1150 . 3225 · ~. 4006
I• ' . . •
0480 2304 3084 5110 ., 1121 ' 2566 ' · 5843' ' 1406 ·
I ··-
9768 4138 1230 5129 3066 4003 . 3240 3576
I;
·3317 0024 0005 0000 0000 .' 0000 ·0000 0000
!.1 . ' l • 1·
Seed 1357 gives; . .
, .'
. . 1
' : ! : • '
""' 1357 8414 ... 7953 ; 2502 2600 7600 7
, 600 :. 7600 ................
, I ~ 1 ' : , t • \

Seed 1379 gives; • I ' I , , , I I / •

1379 9016 2882 3059 , 3574 773i4,.. 81471 .:


3736 9576 6997 9580 · 7764 2796 , 8176 _ • I - • I -

84.69 7236 . 4031 2489 .1951 . . 8064 , · 0280 ; .


.. 1., -

0784 6146 7733 7992 8720 0384 . 1474 -- .


. 1726 9790 · 8441 2504 . 2700 2900 · 4100
8100 6100 2100 r 4100 8100 · 6100 2100 .............. ..
4.6 Congruence Meth~d ~r Residue Method ' ' .,. · I : .· · '
. . I
The most commonly employed pseudo random number ors
genera~ use _the congruence method,
also called the method of power residues. This algorithm is ~escribedI by the expression, .
• ' , ' ~
I I

' ;+1 = (ar1 + b) mod~lo ,m . ,


Where a, b and m·are constants, r1 an~r, +1 a·re ith and (i + 1)th random numbers. The
expression implies multiplication of a by r1 addition _o~ band then dividing by m. The,,+ 1 is the
felllainder or residue,. To begin the process of random number generation, in addition to a, b and m,
the value of r0 is also required. It may be an~ ~~om _numb.er a~~-~s calle~ ,se~d. . _ .. ,
The congru~ntiaJ ~andom ~~mber ·generator may be ~f the additive, .multiplicati~e or mixed
type, Th~ expression given above with a> l and b > 0 is of the mixed.type. 1 •
If a== I. the expression reduces to the additive type . .· ··
'r+ I= (r, + b) modulo m
60 System Simulation
. .
If b = 0, the expression reduces to the multiplicative congruential method . .l l . ~ - .,
r; + = ar; modulo m.
1
< · -' ,
The multiplicative methods are considered better than the additive_ methods and are as good ~s
the mixed methods. · '
The selection of values for the constants a, b and m is very important, because on them depends
the length of the sequence of random numbers, after which the sequence repeats. It is not possible
to generate a non-repeating sequence of numbers with these methods. However; a sufficiently long
sequence can be obtained by making a suitable selection of the constants. Since the number can be .
predicted, rathe~ computed from r,, and the whole string is reproducible, the numbers obtained ~re I

not truly random. They are called pseudo random numbers and hence the method is termed as pseudo 1
random number generator. . .. - . _ , _ , _ 1
. , , . • : .r . ' ,• . ,, r· . , ,·1 ' , ·i I , • • ' , , ~, , ,. • • • ,

. .. Most of the computer languages have. a _standard function for generating random numbers. ,
In. the mode~ scientific calculato~~.; r~~do~ nu~b-e~ key is p;ovid~d.,Whit~ pressed a r~~dom
.numbe~ bet~een'o._ooo a~d 0.99? is ·g~ner~te~. ~---.. ,. '.: _·. :1 -.~_:: ,! .:i. ~.:. ~-; 1 ~,.' '~ - _,; ', ~-

. Example 4.1 ! :rhe pseudo random nun)ber generation by the congruential methods can be
illustrated by taking some values for a, b and m in the recursive equation. . .i . . •,: _•~ ~. .
r;+ 1 =(ar,+b)modm ., '•.'~ (: •t :·;:.:
·It is better to start with a prif!i~ nu~ber as mod~lus m,-and prime multiplie_r a;~ can be taken
any, say 1. The seed r 0 ma~ be ~~y.. _ \. l" . •.:· ·> 1, M: '.; •• ,

(a) Mixed Multiplicative Congruential (MMC) Generator.: ~~


• I. ''; • l .. '~ \ '
I ... . . -·
~l

Takinga=l~,b':"la~~m=l?,_;,,l; ,_,_,_ , ! <c, , , 1,


And letr0 =1 ,·. 1
• 1,t\•.J .. __ ,1 , •• • :· .. , '. · '

r 1 = (1 x 13 + 1) mod 19 = 14 mod I? = 0 resi_due ~4 = IJ .


, r 2 = (14 >:< 13 + _1}__mod 19 .= 1~3 'mod 19, = 9 residue 12 =· 12 ·
' , ' = (12
3
13 /1) mod 19 = 157 mod 19 ~
x ;esidue 5·~·5
, • I
-r ·
r4 = (5 x 13 + 1) mod 19 = 66 mod 19 = 3 residue 9 = l 9 ·
• ' I \ • • • : ' '(' ). I I ,I

rs = (9 x 13 + 1) ·mod 19 = 118 mod 19 = 6 ~ residue 4 · = 4


"· > •. , f • • I ' • • • I •\ •

r 6 = (4 x 13 + 1) · mod 19 = 53 mod 19 = 2 residue 15 =· 15


'1 = (15 x 13 +'. 1) <'mod 19 = 196 mod 19 ~ 10 residue 6 = 6
r 8 = (6x '1 3+ 1) mod 19 = 79 · mod 19 ~ 4 residue3 = 3
r9 = (3 x 13 + 1) . mod 19 = 40 '. mod 19 =· 2 · residue2-_ ;; 2
r 10 = . (2 x 13 + 1) mod 19 = 27 ' mod 19 = 1 residue 8 = 8
r 11 = (8 x ·-13 + 1) mod 19 = 105 mod 19 = 5 residue 10 = 10
r 12 =(}Ox 13+. .1) mod , .
19 '·~ 131 mod 19 =. 6 residue 17 . ,_.~ 17
r 13 = ( 17 x 13 + 1) · mod 19 = 222 mod 19 = · 11 residue· 13 = 13
r 14 = ( i 3 ~ 13 +· 1) m~d ·19 ~. 170 mod 19 ·= 8 residu·e 18 :;; 18 - ,., .
'u = (18 x 13 + 1) mod 19 = 235 mod 19 ~ 12 residue 7 = 7
. ' r 16 -~ {7 x 13 :+ 1) mod 19 "== 92 mod 19 ~ 4 , residue 16; 1.6 .
, 17 = (l6 x 13 + 1) mod 19 = 209 mod 19 ~ t t residue o·= 00
. . - ' ., . .\ '

r 18 = (0 x 13 + t) · mod 19 =· 01 ; ~od 19 = 0 residue '1 = 01 _ .


This sequence 'of random numbers between Oarid 18 both inclusive will continue repeating. The
number 18, which is one less than inodulus ·is called Euler function. This sequence is very short and
is no better than the mid-square sequence: However, if the number chosen as the modulus' is ver/
large, the pseudo random number sequence will be large and acquires the properties a true randolll of
number sequence. · .. 1 • : . . • , ,
p

Random Numbers 61

Random numbers between O and 1 ·can be generated by '


; I ' ~q ..

· R=!l.
I m' i-123
- ' ' , .....
I ''

which gives the sequence as,


I •

14 12
R1 = l9 = 0.7368 R2=
5
l9 = 0.2632,
' '
19 =0.6316 R3 =
9 . 4 . .
R4 =
19 -=,0.4737 · Rs = - =0.2105 · 15 -
. . •' . 19 , ~Rf~ ,)9 ~ 0.7895 •.
6
R7 =
19 =: 0.3158 etc ..... . · -,, .•.. I "' "

l ,,
(b) Multiplicative Congru~ntial (MC) :Ge~e~ator ': ' -i :

r1+ 1 = ar1 mod m b : :. 0


Again taking a= 13, m = 19, and seed, =1
'I O J I I !, -_;: \ j ~! \ , .: \ 1

r, =:_ 1 x q , mod 19 .=: ..'O , residue 13 ~ 13 . .


'2 =· IJx ~~d 19, ii r~sid~~ j's ~--8-:~ \-1 =© .'
, 3 =. 1.3 x_18 mod 19 .:=:. .12 residue _ 6 = _6 · .·. \ ·- •., ,:·
r 4 = 13 x 6 mod 19 = 4 · residue 2 = 2, . : 'l · .,.
r5 = ·, 13x2 , mod.19 ==; l . residue7=7 ,'•,.Ji ..:
r6 = 13x7 mod -19= 4 ·residuel5=15 .;•=--
r7 = 13 x 15 mod 19 = -l O residue 5 = 5
.. .. . ,··1 , 8 = 13x·5· mod19= 3 residue8=8 ; 1 • -·-

e)J;\ r ~·~·/)r9 ,~·: i3 s· X mod 1,9 = 5 residue 9 = 9 . < ., ,.


,,~ = ·,. 13 X 9 mod 19 = 6 residue 3 = 3 ; ./. ! ·: I '

~ ..... r '. ~ t r
r 11. ,=: t\ 13x3 mod .19 = 2 res1duel=l
1. •• ' • \, _ ; •• , • •.: .. ,

.
. • .'
I
The sequence of numbers \ Jbtained is 1, 13, 18, 6, 2, 7, 15, 5, 8, 9, 3, 1, which will repeat
"orever
11 • \ '-• ·..' -',,: · , • · ·• ·.~ /
", I (

(c) Additive Congruential Generator ·: .


rI + 1 = (r1 + b) mod , ,
m ~
a i ::: 1 . C • • ,

Again taking m = 19 and b = 11 · . - - 0

=
, I ' ' 1 ,,

Tak_i~g seed rO 1 . .
r 1 = ( I + 11) mod 19 = 1~
r 2 = (12 + 1.1) mod 19 = 4
• y'
r 3 = (4 + 11 ) · mod 19 = I 5
' l

r 4 = (15 + 11) · mod 19 = . 7


•r
.\
r5 = (7 + 11) · mod I9 = 18
r6 = ( 18 + 11) mod 19 =.. .I0
r 1 . = (,10 : }, 1) . ~o~ ~ 9 ~ , ~ .
r8 = ,(2 + 11) mod 19 = 13 i ••

r 9 = ( 13 + 11) mod 19 = 5
r 10 = (5+11) -, modl9 ~ 16
r 11 = ( 16 + 11) · mod I 9
/ I :
= 8
I •

r12 = (8 + 11) mod 19 = I ·


,,. .. lJ •
62 System Simulation

A computer program in C language for generating the random numbers by the mixed
congruential method is given below: : {,~ O . ·O O f / J
#includecstdio.h>
#includecstdlib.h>
I )-\ 6 6 8 s~II •.
#includecmath. h> - ·
main()
·c-s--
{ /*Mixed congruenti~l method of generating rando~ numbers
a,band m are constants, the value.a which are to be suitablly o~ 1

selected and entered.


nn is the number of random numbers to .be generated. . 1 ·
seed is the starting random number, which also is to be
.. ' • I \ • • • ~I f •

entered. */

t"' I

int a,b,k,i,j,m,nn,seed,r[SO];
priqtf("\p~Enter the· INTEGER valu~s of a ; b,m");
I ....,, f ·l .. , , , ' r , , : ' • · - •
scanf("\d.:: \d \d",&a,·&b,&m); · ·• •. -' -
print;("\n Enter -the INTEGER value -of seed ' ");
· I . , , , •1
scanf1( "\d", &seed); , 0- ' :- • ,,•·_; ,, •• ,. :

1
print: f ' ("\n Enter the , number ·of·:•random numbers to be generated•);
t ... . .
scanf ( "%d~ ; &nn) ;. ' . ' -
/*a=21; b=53; m=lOOO; nn=30· */ , ,
'· •. • -
4 • ' ' !. .,

r [ 0 J = seed; ·', . ;,. ·. ,; : . , ,


for(i=l;i<=nn;++i) · \-
r.[i] = (a*r [i-1] +b) % m;
printf("\4d",r[i]);
I . . , >·
}
.. ...
}
. ! I •
The output of the above program ~s given below :
145 98 111 384 117 510 763 76 649
682 375 928 541 414 I . 747 140 593 506
.
679 312 605 758 , 971 ,, 444 377 970 423
936 709 942 835 .- 588 . 407 474 007 200
253 366 739 572 . ! 065 ', · 418 I 831 ~04 637
430 83 796 769 • r 202 · · 295 53 281 282
4.7 Arithmetic Congruential Generator .
Another kind of pseudo random nuinb_er gene~tor is the ~ithmetic congruential algorithll
which is given as, . · · '
1
'i+i .'= (r,~1+,;) ,mod.m
The'. process starts with two random numbers, ~~ich a~e added and divided by.m with
residue giving the third number. Then 2nd ~~ ~rd numbers _result in~o 4th number, and so on.
flsndom Numbers 63

for example,
',,
Ifr,=9, '. '.
1,

,.
: •

'• .. \

·I rJ == (9 + 13)°mod 17 d 5 :i. ' . ' '· '

' .. •


r4
l

~
'
• .

(13 + 5) mod 17 ~
'

\
,• I.,·

.


•,;

....
\,

J
• ,{ 1, 'f
• ,,

· · '
'

·i
• • ; ,
..
~ ••)

I • ' { J I

.· • t
i . ..... ! ~

.., \
. ··...:: ..

·'· , · 's==(5+ l)mod 17~6 .J. '.i ! .• ,.. J ,. , I

· · ,6==(1 +6)mod 17=·7·•; 1. • · • •1 1 • • :· . •: ; •. . : .. 1

if
r~==(6+7)mod 17=13 i. ·, : , ,. ,: · I . • i I I

. ;s·=
(7 _+ i3) mod° 17 ~-3 .! ' , • r . • , •

•I
r<> = ( I3 + 3) mod I 7 = 16
'10 = (3 + 16) mod 17 = 2

and so on as 1,3,4, 7, II, 13, 8,4, 12, -.16, II, I0,4: 14:' 1, 1 1f1'6, 14/ 13: 10,6, ......
This results into quite a long sequence. . .
Remarks: Some studies reported in literature indicated th~t the multiplicative congruence
metho_d is superior to the additive method, and that mixed congruence methods are not noticeably
better than simple multiplicative methods._In each method/ the quaJity ·and length of the random
: number sequence obtained depends upon the valu_es of co'nstants, the selection of which is a complex
·problem. ~o be considered random the sequence of nu~be~s produced must meet·various tests to
ensure that they are uniformly distributed and that there is no significant correl_ation between the digits
of individual numbers and between the sequential numbers. The length of the sequence before it starts
repeating should be·sufficiently long. '
1 ••• ,• i F >I } '• • • 1 ; - ' .: ! ' ' ~\

According to the available guidelines modulus m should be the largest prime number that can
be filled to the computer word size, and the m~ltiplier a shoufd be ~ positive primitive root of m. A
· po~iti~e pri~itive root is .defined as a prime factor 9r ~ny positive integral power thereof. ·
- I t• •
• ,. ~ .. , 1 .' I r ! ' , i ',, • .. ~ 1·, I , , I , I • r ~ • •
1

. . a= 55 =3125-arid m, =, 2' 35 - , "31 = 3435973837


: ~·
is one combination
. . . ' ,· . '· •.' ~ i _, I ' \ ,
suitable for a' 36 word size~
• • , • ' ,• .r •., : f j ' • •

computer.
a= 75·= 16807 and m = 2JI . . '. ' ·= 21°47483647 is 'one combination•'suitable for a'32 bit word
.
s1zecomputer. ·, \
·· · · · :.c •.·· . ,.• ,
,..
... , ... , ! , , · · i ' · ..
''

These values ensure. a sequence of over two billion ·rancfom nu_mbers. Further,· specify a seed·
r0 = 123457. The first few numbers ·generated using the .above values for a, m and r0 are as under.
' (' I ~ • ' I • • I , •

'.s (12-34~7) mod (2J_


' . '
1
• , _
1
, • ,'1 ~ :. I_} ~ -~_,_0~1•~4~,'7.9_~
. r, . I ·1
I ,
·.,

R1 = 7T = 0:96~2
' 2 •• !• ( ) I •'i '
,; '.: ,· .I
.r 2 = 75 (2,074,941,799) mod (2 31 - I)= 559,872,160

r2 .
. R2 =. 231 = 02~07, ',,

r3 = 75 (559,872.f60) mod (2 3 i - I)= 1,645,535,613


r, ·. , ' . ' ' "' .
R3 = -tr = 0.7662
;: • ,- ; , • .' ,j. ~

.. 2 . . ' .• : ..

. In·this case while determining random' number ~etween 0 and I, ~1has been d~~d~ not by m
but by m+ I. This does not make much difference, as 'the value of in is very large. · . · 1 ·
64 System Sin,tJI . ·.
at1ory

4.8 Combined Congruential Generators


The random number generators discussed so·far, may not be adequate for soine
corn 1
ted bef!ee~
applications, where hundre~s and. thousands of el~m-~ntary ~vents ~ust ~e simula
ds of u a
significant event occur. The s1mulat1on of complex computer networks, m which thousan
are executing hundreds of programs, require
' ·
· substan tia I · · d o
· IIy onger_per10 s. ne met od of nicersers
h
such a way t~ng
such a demand is to combine two or more multiplicative congruential generators in
at
the combined generator has good statistical properties and a longer period.
ors, wh
If r;, 1, r;, 2, ....., r;, k are the ith output from k different multiplicative congruential generat
is m _ I, then
the Jth generator has prim~ m~dulus m1 and the mul~iplier a; ~hose~ so that the period 1
the combined generator will give, , , , ol ~
I ' j

with .. • I , I I.•,• r .

• ' . J •I -· J I
r-• l . •
. I
. )

, I -' , , J • r>O , •

m; . , ; l • ~. t '

m; ..:.1
- - i r;=O .
, . l
. m; • I • '

I • f I
.I '
• J . •
'.
J

· · The maximum possible period.for such a generator is , '. -',

• _• • · - ; : P= (m,-l) (m2 -l) ...... .'.. (mk-l ) · ·. ~ . 1


, ••• ,, • .', , •• ,
1 • \ 2k -1 · \ I • ., .I . . . .· , I , 1 •• .J ' • J .,.

~ l' 1· f' ' • ~~ - I ;


~ J •• 4 ., ..
• • •• f •• l - •. . ' : .. . ;
(. • '~ '

35
One such a gen_era!or s_uggested by_Le 1?c~y~i)s fo~ k,=f 2. Values of ".'i an~·m2 a~e 2147~~
be
and,. ~-1474~3399, while a 1 and a2 are ~001,4 and 4069~.- lhe value of seed r 1 0 is selected
I and21 47483 562an dthato fr; isseleciedbetw~en ·l'and2147483398. ·· : . ' :.i : '. -.
0

4.9 .. Qualities of an Efficient Random Number Generator (


seque
• It should have a sufficiently long cycle, that is, it should generate a sufficiently long
· ,
, . ..: . of ~an,d~m numbers, b.~fore beginning to repeat the.sequence.
1. •. • The random numbers generated should be
repHcable, that is by specifying the s~arti
wh
conditions, it should be possible to obtain the same set of random numbers t as and • .. ·' . l . \

syste•

desired .- Many times common random numbers are required for the comparison of two
.

den
• The generated random numbers should fulfill the requiremen~s ofuniformity_and indepen
• The random number generator should be fast and cost-~tfective.
• It should be portable to different computers and ideally to different programming languag
4.1 OTesting Numbers for Randomness I

A sequence of random numbers is considered to be @ndom, if;


(,) The numbers are un'ifonnly distributed, t~at is every numbe r has an equal chance
' ' .
occurrence.
(i,) The numbers are not serially aut~correlated. This means that there is no correlat
ion be
e
adjacent pairs or numbers, or that the appearance of one number does not influenc
appearance of next number. The sequence 1, 3, 5, 7, 9, ..... or 1, 4t 2, 6, 3, 1, 4, 71 s•.....
1, 3, S, 2, 4, 6, 3,·s, 9, ..... are serially correlated. , .
,65
om Numbers
-,:tsnd
st to en su re tha t the ran do m numbers are uniformity
8
te s, which are used . ·
; •There ar; number ~f autocorrelated, sotne of which are discussed below
, : • • •
1

n all y . ,. · ·.. , .
·distributed an a~e not se ·: · · -
,: 11 Unlfor~it~ Te~t
sic t~~ t tha t.s ho uld al~ a~ ; be pe~~rmed . v~lid~t~ t~
st rmity .orTw frequency te~ t is ~ ba . 1mov test
· Thme te
do numbe,r
of unifone
ge rator o fr
nc y tes ts are av ail ab le. They are Kolmogorov-Sm with the
. eq ue niimbe rs'
a ran . •
~o th of t~ es e tes ts co m pare the generatelrandom
and th~ Chi-~quare~ te~t:
•. • •
• • • : . , ... ~ .
·.; •• :
. . . , · ,. · • • ,. , . •.

the~reti~al ~~1form d1 stn bu t~ on .


·,
1
:_, i .·. . , ., .
1
, . . : .: ..
ov Test
fhe Kofmogorov-Smirn un ifo rm distribution to the em
pirical cdf,
ntinuo us c
' df , F( x) of the
This test compares the ·co lar ge st_ ab so lut e de via tio n between F(x) and SJ x)
do':11 numbers. The le as function of Nin Appe
ndix
sJ:x), of _the samp_le of Nparan red with the critic al 'va lue ,· wh ich is av ail ab
mimov
is determined and is com Th e pr oc ed ur e of em ploying the KoJmogorov-S •
els of significanc
Table A-6, for various levillustrated in the next example.
e. _,·, · ·. ~ ~ · . · ,_
uniformity test is clearly rmity of
is to be pe rformed to test the unifo
. , . ". ~
Jmogorov-S m im ov tes t
. ·: · Example 4.2. 1:he Ko th a level of significance of a= 0.05. : ·_ ·
rs wi
· following random numbe ;· .65 · •. ·. ·
J -

1,.23; ·..86, _. .41, ;64,:· .so


~ 4, .8 9, .J J, ;.6 given
_ ·.2
· in Ta ble 4. J.: Th e top row ·of th~· table lists .the
e test ar~-gfy e~ t~e numbers
; The calcu)ations ·o f th ~.J0. In the secon·d row,.
random ·numbers R; ( i l; =
N) 'in the· as ce nd ing or de
;
~
i/N
1-l
va
e~e
lue
N
s are lis ted . In ~he third row ~eviatioJ)n, .
piricai dfstributfon, {e.' /'" .l. ,''. i:: -.: ,:- .,, f", ' , _ , ; , , . } , ''. : (i ~
are ·computed fro~ the' em - ft
• g- i ve s IY ,. wh ile in. ~e fourth row, the deviatio~ R;
_
; ; ::-- R; is c.omputed_m
aximum of which ·; .. 1.· , :• = ·· . . · · ; ,
{ .i

ve ni r. ·1- /11 .'·· ,. ··. ,.: f., 0

fw hi ch gi •
omputed,themaximum ·o
• . . _·..,
· ·sc .
.... ,., .. <, ! :: ' :. ' .I ; '; .. . I ... : -
;;, max (!Y, lr )i ' . I

The' largest deviation,.'D


I ·
ati on D ~~ .I 5. :_ . . ·
in:g' the ! lar ge st' de v1
i. · · ·, From the tab
le, l)i ' ~ -0. J5, Ir:,: ~.13 giv /o r a~ _o.05 ~nd N := IO is·~.410.
tained fr?m ·Ap pe nd 'i.~ ·Ta ble ·A ~6
fonn
The critical value of D ob I va lu~ , the giv en ~aridom _n°!11~rs are ~m
Since the computed value
o:
J5 isf Jess than th~
cri
'
t,
. c
i
rit
~a
ic~
.1 _ va lu e\1 s 0.3 68, w~1c~ agam 1s m or e~
~ ?. 15,
ce. At a' = O. OJ , ~
at 95% level :of significan level of s1gmficance. •~
1 _· .

un ifo rm ev ~n at 99 Yo
numbers are ' ~ .1
hence, the given random : ,i Ta ble 4.1 ; . - . , 1; , I .
:, ·:
9
.4 J · ' .50 ·- .6 I ·.. .
.64 . .65 - .86 .. ·.8

-::~ · :~~:·<:i.
.80 ' .90 ' ._ 1.0
<so :· -'.60 ' : .70
:N _ .
06 .·. .4,? ). ' 00 · L _ · ' , ·, .06I
, , .• 04 I · .-,_
..15• • .. ··.04_ ..l .~:.1 I
' I

.• ,06 -- . . ~- -
· - R - ' ·11 ;_1, ; '.1 )0 .• J • ))
• , - -~-- · -•~
i/N i ·'. • •,
_ , .. ·. . .. -.,
... _·R; ·u:· ,.
1)1N ·_ .JJ ·_. __ .13. ___:._ _.04
. ' :i 1 .. 1 • •
l

1
- - · ,.~ ~ *• --~••
i ·•

4.12 Chi-Squared Test sta tiStic , , . ·. : · · .-: ~ _·· ~' ~: ,..' .:


the sa m ple
Th~ Chi-Squared test uses ; t .-: . , · •,. ·.
. ,· ·•
2 ~ ~ ( D; - E;)2_
, ., . .
X o . LJ E. 1
and n is
•.
;,.i ex pe ct; d 'n~~ber in the Ith_·cl_ass gi~en by
. :·
1.~ th e _it~-~ a~s,
E. ' is the
expected nwnber in each..•.~la:: , _,. . •
ss is
.
observe~ numbe ~ £.. the
: ·
- • r
where O; is thecla
r of sses . Fo r the un iform di~trJ ution, .,• 1:,;·__ \ _-.: 1.
the numbe N •., -. · ;., ,,
;· E--
(

..
for equally spaced class
.

es, where N JS t
'. -~=
total
I

ly
nu
th e
m
ch
be

r
i-s
of
qu
~b
ar
se rv
1 . ":

e d1
ati on
• .
s. It can be shoW

str1but1on w1 n
'tf j - -1 grees · de
h that ~e- .
..
'of
X z_is approxim ate ~- -- ·• -- -- - - -,
lampl ino d' t 'b . t' of - ··--- --·--- ~
O •al
... ... ... - ..,- - - -·-·~
,-- ·
--..:. -- . IS fl U JOn ;
... ~---- .....
66
System Simulation
This_test involv es the classif ication of 500 random numbe rs betwee n 0
and· 1 into Io equ
interva ls, that is numbe rs less than or equal to 0.1 less than or equal to 0.2,
0.3 J ..... , 1.0. A bar ch~
1
or histog ram can than be plotted to illustra te the unifon nity of distrib ution.
If the _5_0 0 numbers were
distrib uted among the 10 classes , with perfec t unifon nity, all bars will
numbe rs. · · be of equal length of
· · < • , • • • • • , • , ,•
50
· : ~hi-s~ u~re is a ch~~acter_isti~ of th~~, distrib ution, whi_c h. is a meas~r
~-of -i~s. random.ne~s, ..Jhe
stat1st1c Ch1-squ·are is compu ted by subtrac ting the numbe r of rando!!l n_
umbe~s. in_each clas~ from
the expect ed numbe r (that is 50), squarin g the differe nce, adding the square
s for the ten classes, and
dividin g the sum by the expect ation (50). ,,. l - .. , " >~ ~; i \-.·." ., . , \ · ,
-1 _ F,or ex~mp le, if 47, 49, 55, 51, 46, _53, _ 5 _1, 43_, 4~ and 54 are the .numbe rs in tq classes.
l ., Then their differe nces from _50 are, 3, 1, 5., 4, .4, 3; 1, 7, 4, and 4~ and sum
of the squares of
_differ en~es is9+, 1+25 +16.+l(>:+-,9+, J +-49+ _16t16 =158 .. _
.:: ·. _. ,;_ .· ,
V • • • .- 15 8 .. " . . .,.-t
I - •
i: ' . ·-. ·1 • •
J ... : j , I r: . -. \ - . ' : .· . ~
f I. • : :
1 : • · l .'.' >
;
Chi-sq uare= - 1

50 = 3.16
I I •• '

· :)! .~ .. . , . . .
.l ~ i_...
t . • -~
(I.''.,.. J r:..:
' .. , '
:.1 . i ..·. • I ,_ ,'J • h J ;

There are tables of Chi-sq uare that will tell us about the goodne ss of the results
. The acceptable
value of Chi-sq uare will depend upon the degree s of freedo m which are one
less than the !}Umber of
classes , and the level of confid ence we wish t(? place in ou~ results . In the
presen t case, since there
are 10 classes in which we have divide d the random numbe rs, there are 9 degree
s of freedom. At 95%
confid ence, level the ~cce.pt able v~lue .<;>f rhj-sq uare· f~r 9 degr~·e s ~f_free
.d o~ is 16.~.l ~ _(Appendix.
Table A-2). This means that when the value of Chi-sq uare is less than or equal
to 16.9,. there are only
5 diarice s out of l 00 that o~r results are 'wrong . . .. . . . , •· .
l 1
• •
, . .· . . .
, , ., •
. Chi-Sq uared Test can be emplo yed to compa re differe nt sets of random }

numbe rs or different
random numbe r genera tors. For each set of random numbe rs the statisti
cs ,C hi-squ are is computed.
The one-w ith smalle r value of Chi-sq uare is more unifon nly distrib uted.
,· .. , ·,. ,. ". ; ,. 1 ;-
• .L 1 ~ I • • • J · I 't • 4. l
Example 4.3..The two-di git random numbe rs genera ted by a mul~iplicative congruential
method
are given below. Determ ine Chi-sq uare. Is it. accept able at 95% confid ence
lev°eJ? ~ _
·, ,.·._ 3 6, (·•91, .. 5_1, _. _02, ..5.
1 4 _
~ ·:o<>> .-. .s~~ .:·06: : 58,'~ 9i_ , -,_-.5~,.- 01, _. 4·8 ,--_-., 97, ,_43,
,, .22, 83, - 25, 79, ·.1 95, 42, , 87, ,- 73, l7, .- 02, : 42, , 95, · 38, . 79,ri, 29,
65, 09, 55,- _; 97;·( 39, . 83, .· 31;· • 77, ,,:· 11, .- 62, ' 03, . 49, :·. 90~ -- .37,
;; 13,
_ 17, 58, 11, 51, 92, . 33, 78, . 21, . 66, 09, 54, 49, 90, 35, 84,
-- - - 26; 74; · · 22,"- 62, . · 12, ~-:. 90, , 36,- · 8~, .. '32, 75, .. 31,
; 94, - 34, · 87," 40,
.- 07, 58, 05, 56, . 22, ·, 58, 77, 71, 10, 73, 23, 57, 13, · 3~, · 89,
~;22,I l•~8, o_~~ 44, • 99, '2 1, 26, 85. 8!, • • \,:
· Solution: The given 100 random numbe rs can be divide d into l 0 classes as
given belo~:
· ---:---· · Class Count - -· " Frequency · · · · · Di.ff · · ·•-- -· (Difff__ ·_··~ ·
O<rS lO ************* 13 3· ··-,• 9 •-~
IO < r S 20 • **** *** ; 8 -· 2 · -,_, f . 4
20 <.r S 30 ********* 9 1 1
30 < r S 40 • •• 0 •• ** •0 • • '· 13 i
'
" 3 9
40 < r s 50 •••••• • .. 1 3 ., . ,, 9 \
, __ S0<r S60 ., ••••••~••**•• 13 3 · ·1 9
·· 60 < r S 70 •••• • ·5 S 25
70 < r S 80 •••••• •••••• 12 2 . 4
:_. l , 80 <, s 90 1 • , ; ( , ~···~·······
12 , 2 •, • !J.•
~~- ~~s 100 •••••~ •~ --.. , .r' ., ~ - :.. • : . 1 • 2 , .:, ,L . . . . . .- 'Iii
om Numbers 67
f'Bn d
i ! ' . I
78 . _
Chi-square= To = 7.,8 , J , •I..,
' J . ,

squa re
· · __For 9 ~ O.- ) degrees of freedom, at 95% confi'den
1 1 ce lev~I, the acceptable valu e of Chi-
15 th of random numbers is acceptable, so far as its
is ·16.9) ~hi_ch , ~ore_ a~ 7.8. Hence, the given set _. , _, . , , . :
unifonn1ty_m d1str1but1on 1s concerned. .
Aut oco rrel atio n . ,. . . ; : , .. : , - · 1 • . .i-
4 .13 Tes ting for
necessary te~t for r~ndomness; ~ot a sufficient
.· The uniformity test of random numbers is onty 'a
orm,' and still no{random.' For example, the
one. A sequence of numbers may be perfectly unif
would give a perfectly uniform distribution with
sequence• I, .2, .3., .4., .5, .6, .7, .8, .9,. 1, .2, .3, ·.i... ,
no means be regarded as random. The numbers
the chi-square value as zero,' But the sequence can by
say J decides the next, ~hich is to be .4 etc.
are not independent, as the occurrence of one number ,
cent pairs of numbers.
this defect is called 'serial auto~o.rrela_tion' of adja
es use of a 10 x 10 matrix (checker board).
The Chi-Squared test for serial autocorrelation mak
sented both alo-ng the r~ws and columns. If
The 10 classes descri_bed i!l the uniformity test are repre be will
100 bars, one for each cell of the matrix, .
. the·classes are to be represented on a bar chart,
of 1O, random numbers are divided into smaller
. required. To reduce the number of groups, instead
than or equal to 0._33, less than or equal to 0.67
number of classes as 3, or 4. Three classes will be: less
and less than or equal to 1.0. With three classes
in rows and three in columns, there will be 9 c_~~s.
' · ·: · : ·.-
Let us consider the following random numbers :
87 · 83 26 01 -91
49 95 82 ·· 19 •• 41 ·!~, 31 ·- f2·,·,: 53 '.·,. 62 ' ·•: 40 · • •••

- 57 88 . ' /38
: • I ! •

35 ' 71 · 57 . 27 85__ , 52 · 08 · 35 '


I ,

55 38 75 90 1
79 68 . . 20
86 ' -29 . 18. . 09 ,; '96 . 58 22' ,' 08 ~
. 93 \ 85 .. 45
77 1

11 ·- 78 . 93- . . 21' : 13 ,, 06 ' , 32 ,63' :·,: r79' ' ·54


1

~ ' ' ~i
67 I '~' 35 . 18 _' • 81_
"'
~
. 40
I , f

·.. 36 ... . 80 ___ 7~ . __ 9_5 .. -/25 .. 52. ---- .. - .....


' "i ;· • .. I "
. • • • '

___ 62 _ 13 -_ 76 __ ·.74 ~':'.-76 .-.. A5 _ 29


Th~se 73 random numbe~s giving ·72· pairs , ar~ gr~up~~ _if!t~J ~-!~!S~S -~ith _~xp~~ti~I_! of _8 !~
· - - .... - · · ·· . · • · · · ·' ' l' · • ;
-~ach gro~p. ·
, • Frequency ·· Di/I (Dijff
Class Count
'' _. 1.
R1 s; .33 & R2 s; 0.33 * * * * * * * *·* 9
7 I 1.
R, s; .67 & Ri s o.33 * * ******
·2 4
R1 S 1.0 & R2 S 0.33 ******* ~ 6
' 6 2 : '. :. 4
R1 S .33 & Ri S 0.67
*****• *
0 ~ .',. - 0 :
* • • ** • • • 8
R1 S .67 & R2 S 0.67 I;
• • *• *• • • • 9
R1 S 1.0 &-Ri S 0.67 ,7, ). .
R1 S .33 & Ri S ~ .0 ••••••• 1
1.l, s .67 & Ri s i.o •••••• •• • . 9 I
9
1

R1 S 1.0 & Ri S 1.0


•••••••••••• 11 3
24 .
72

i ;•r •1.J 24 :>. -" , :i 1, -t, •-"' C -· ;J~ __ . • ; .>'. ;·. J _y~, _
Chi-square= 8 = 3.0 . _.
b determined by taking the pairs of randwhi. om numbers.
· · ch falls in
coun ts in di!l"eren t class es h::ed ;e~ l .0. Then the ~ext pair is .95 and .82
.. The
class R1 S ·
67 2 f; . 1 R S 1 0 and Ri s 0.33 and so on. Since
~aar -49 and .95 falls m 11
class R1 s 1.0 and R2 s I.0, Pair .82 and .19 a s m c
ass 1 •
68
System Simulation
the total number of pairs in 72, one less than the num
ber of random n~~bers, the expectation is
that is 8 pairs in each class. Then squares of differenc 8 - --

es .(fre quen cy-· expectation) are detennined \ T • ' 'r '

and their sum is obtained, which on division ~y expectati


on gives the value of Chi-square as 3.0.
In this case there are two variables R and R and hence the
I 2 degrees of freedom are nine minus
two that is seven. The criterion value of X 2 (chi-squa
re) for seven degrees of fr'eedom at 95%
confidence level is 14.067. The value of Chi-square obta
ined for the given set of random .~umbers
is well within the acceptable lirnit, and beAc;e, tbey ace
not serially autocorrelated. ,- . ·
.
..;_;_:,. :..:.,;_.: .;.;.::._ _ _
_ __. ~ ' l ,.. I ,
, Example 4~4. Given below is a sequence of rand
.. - ' • om numbers. Perform the.Chi-~quared tests
• • •

to check the numbers for uniform distribution and seria


• • f • - • • -· • ,: -

'l autocorrelation.
1-
'., '.:.

· ·
• 1. ' • •• ' t • ' ' ' -•• ' r • • ' ~•'
G • • . ,. 07 . i. 05 .',.96 .
l I '"• ' "·
)4 . 10 _. 90 --· 21 ,1, 15 .~ 84 e · 28 .· 20 ··- • .1, ;

.78 , '. 35 25 · , ',


··. '- 72 ,' 42 ·· · 30 ·: 66 '' 49 •.'· 35 - 60 ·· 56 \ i, ~.

-'40 - , 54 .J ' 63 _; - 45 , 1 48 '-' '..: 70 ·· •;·;.-


50 42 11 55 • _. .36 1 -~M ·60' :>3h '·· 91 :-:"6 s :·:. ·24 :· · !10 : :_ 1·8~ _,. i,°'l 98 ;
••~·. ••' 01' - 75 ' V 2 •: 14
1 1 .,.. .--; :i · · 1
"i
80 I: " 'o{ •,:: 1••r :(;i i•ss' lo,\ 1 1
,, '90 •.-• is'.' , 95 \ > ' 96;' 2s'•~ 90 . .
. ' •~ •· · ~,.{1 ,l ,,l,·, .. , :; ·t :- ," 1;:.,..,. •. ~- •.;.a 1
' 1
e

-• r 84 42 t 05 ••, 78 ' 49 ,;, 10 ,72 11 ,56 : 1s


I•
, ·~--" ,.. -:. '._, 1 : , •\ ,
• t., 1 • <I . ' 66 . ' 63 . ,, 20 , ' 60
, "'
-70. ,.._ • •
,, , .• • ' • \ i ' , ; I • ,, ~ j _. •• ' •• , • ,
['. ·25 ·; 54 '. ·t 77 ; 30 ·•, ,48 ,·_a'.· 84 .:. 35 ;,·: 42:i
f I • : \

91 •j'fJ 40 • .: 36 .. · 98 , _ 45 ~ 30 · ,_:
\ 07 •50 • '24 '' 14-.J , 55 :~',- 18 ••• 2, ~i,.:',\,'.••
I
·~•,;;,,,i; •:'·••. > ,' ~ ,, ,,:,:
• I , _. " P ' • , , 1' :,.,',: , j _. ,,. ~,:~ :, ,': ,\"'; f { ~ ...<}~;-,.- ~ ~
I'°; ..
r ,-•.-•• :;.; ,_/( t,. ,
4.13.1 Uniformity Test ' I

,, For checking the random numbers for the.uniformity


, we will divide these in 10 class and take
90 rand~m n~inbers, to. have the ~xpect.~d valu~ in
each cl~ss as 9..
,. . ' There are.ten dass es and one variable, giving 9 ~egr
i. ; ~- ~;· r .
, f J
l ._ • ... :-.
ees
1
of freedom_. For 9 degrees offreedom
...
a~ 95%, ~onfi?,e~c~ le_vel, the acce~tabl~ value_.~f· x2'~• '}s f.1 •. (• -...' { • •

1
up}_o 16.19: Our,yalue,~f x. 2 . is we_ll wi~in
the acceptable. hm1t a,nd h~n~e, the random nun1bers ,i~ the given s~quence are ~niform~y distribute
d.
,, . Class .,,. _c;_<!_unt_ .,.,; ;':: -~·. ,· .., .,, ._._ ,. ,; _Freqlfency_ ~
!. ' ,
, , .· , .(Di jff .·
~ .... .. .. 0 ~ ~ S.. 1,0 -·· . . _ ********* 9
·11 SR$ 20 '1 ,Y •, '
9 0
. ..
. . . . . .~ . - · •· • • • ... # - - ..... - • - -...« ·- ·· ,. ..... - • • • ..... ~ • -
* * * *,.* * * * * * * *
• .. •
21 SR$ 30 ---- ........ - -·•· --- - ..... ..- •
' '. 9 .·
l
( !t
12 .
31 SR S 40
41 SR$ 50
· ." 8 . \ 1
;¢ .•
12 ., •
51 $ R $ 60
•·· . j 9
* * * ** * ** * 9 . .- 0
6-1 S R S 70 ·~-, * ***** • * 8 ·: . :, . . ' 1 .
'11 IsRs 80 8 • , ' I
"

:• • ,1 ·.'
81 SR S_90 ***•••*• ., ~ .. ,,
8 •• I • t' (
:. '1'
*.
(

91 SR S 100 _ *· * •• * '• . .:..


\ ... ..,_ '/. ·! ' ,,. ,,
7
:.- - - - - - - - ~ - - . . . . : . . . ; , _
_
' 4
_ _ __

90
..
· <;hi-square; x2 ·=
.
. 26
9 = 2.9 .
ltlb¼ ~\" I ~
··- -·- --- 7})P ;_-~ -·- tA\ lb -
1W F '0 ., :•
-·-i --,t
~· ~amt-1-~dvt
26

f-' '· ' •~ ' ·· I I ' •


4.13 .2 Chl-Squa,:ed Test for Autocorrel~tlon 1 • .- • /

.
~ ·;. ' F~r this test the overlapplng pairs of random numbers
are to be taken. ·Taking threre
.; J3; 34 to f,7' and 68 to 100 for each random ·numb
er in the.palr,the-number b f ~-
-.s is obtained as·follow~ Since .there are- 9 classe~,1the
expeci.tron val\lo,~ $) .l
69
ndom Numbers
ft8

Ri Count · Frequency (Diff)2 ·

--- s 33, $ 33 • ••• •••••• . IO ., ,o ' ..


S 67,
S I 00,
S 33,
$ 33
$ 33
$ 67
.........
• ••• • ••• • •

• • • •• • • •
;i
10
9
7
_./
>
0

~ 67, $ 67 •1• * ••• ••• * •• * ••• ••• •• 20 100


S 100, $ 67 • *• • • • • • • • • • II I

~ 33, $ 100 • *• • • • • • *• 13 9
~ 67, $ 100 • • ****• 6 16
~ 100, $ 100 *••* 4 36
90 .
I 172
~ • .nr
. · I 72 . <n
v tflv»
11
1 JU YK,,
~f
· -'"
~ ~,., , •·t, c.,
Chi~square (x 2 ) = W = 17.2
. . .· ()~ J-'
e,/ ~il b/ /0 ~ £,
2 -at 95% _con f~ ence level is 14:1, wfl ich is
The en.tenon v~lue ,of x for _7 _d_egrees of fr~e90~
sequen~e~Thus, the given sequence of random
le~s than the value we have obtained for,,the given
ce level:
numbers is serial1y autocorrelated··at 95% confiden
• I

4.14 Poker Test \ I ' ;- , .)


l

p.ok~r. This test not only tests tJie randomness


~ l

This test gets its name from a game,.o( carqs calle g


Afi~i~g of each num~er. Every random number
of the sequen_ce of nump~rs,_,but a)so the. digjts COpl
ed as a poker hand .
of five digits or every sequence of five digits is treat
. 71549, are five ,d.i.ffer~nt digits
f' • ' \.l • •

I l

r,~5137,w~u,l,d be_~ p,a,!r . I•

33669 would be two. p~irs .,


55513 would be three of a kind
44477 would be a full house
77774 would be four of a kind
88888 would »e five of a~kind·
of the 'cards' within a 'hand' is unimportant,
The occurrence of five of a kind is rare. The ord~r
t~e straights, ,flushes and rpyals ,of the poker gam
e are disregarded in Po"er Test.
e digits each, you may expect the.following
In I0,000 random and. independent numbers of fi,v
distribution of various combinations. 30.24%
3024 or
Five different digi ts 50.40%
Pairs 5040
10.80%
1080
Two-pairs 7.20%
of a kind s 720
Three 0.90%
90
FuH houses ' I 0.45%
kind s 45
Four of a 0.01%
Five of a kinds
Example 4.5 : Poker Test
A sequence of I0,000 five-digit random num
bers has been ~e~erated, and_ an ana~ysis of
ng fiv~ different d1g1ts, 4935 havmg a pair, 1135
numbers indicate that there are 3075 numbers havi
70 System Simulation ..
having two pairs, 695 having three of a kind, I05 having full house (three of a ~i_nd and a pair)
54
having four of a kind and one having all five of a kind.- Use Poker Test to determine if these random
numbers are independent, at a= 0.0 I. · ·
The calculations of x,2 are given in Table 4.2. t ,
Table 4.2
Combination Observed
Distribution · Distribution Expected ,. -(0; ""." £,)2
i O; ,' . £, . . . £, .

~ive different digits 3075 3024 · 0.8601 -


,.. t
Pairs 4935 5040 2.1875 :
'
_ 'fw~-p~i~~ .. _.: . _ 1135 1080 1-.8750 -
Three of a kind 695 720 0.868
~ "'., - .-~ • l Eull houses tr-- -· ' ~ ;·,- C• i "' -- iQ5_) f(} 90 : .-·· is' -
' • '-
Four·of a kind,
i . , ,, ....., .., ....
:;;.
i , ..;; , ,-..Ir-;;,.,,.,
• ..1.
'- I or.;. .1w,. I..
..,: 1 -kth 54
I) ,.,
~, ,~,, -~.1
• 45 _,;
• '
J
·•
•J
,
1.8 '
i. )

Five of a kmd 1 .. , , ; J • _ , 0 I : .. ' \ 01 . · - , 0.0 ·


· 10,000 .10,000 . 1().0907 ...
The appropriate degrees of freedom -in this ,case are 6, one less than the nulJ!~r of combinations.
The critical value of x,2 for six degrees of freedom at a= 0.0 I. is 16.8. The. value of x,2 obtained
from calculations is 10.097, which is less than ·the critical value. Hence, th·e hypothesis· of
independence cannot be rejected on the basis of Poker Test. r • ; • '. ·· '· _· ·' :--: • · · J • •

-' Exam pie 4.6. Use the mixed congruential method 'to generate the following ·sequence of random
numbers. •· ,_. · , · · · r • •. ,• •• •
1
• ,
t • •

1
,
f' ~
•·

'-
'f

(a) A sequence often two-digit numbe~s, such·th~t rn~,;; (ilrn 53) modulo ioo. Take ~ = 52.
0
+
(b) A sequence of ten random numbers b~tween Oand 3 1 such that,
·. rn + 1 = (13rn + I 5) modulo m.'Table r0 11. ·
Solution:
'
1
·=
ti•'·.,,· • •:r '
(a) rn+1= (21rn+ 53)mo~ 100 " ' ) , .. r·.
Given r0 = 52 1
' '. • ,f • ' • •

r 1 = (21 x52+5 3)
mod 100 1145 ' m-od 100 = 45 1 =·
r 2 '= (~1 x45+5 3)
mod 100 l= 998 · mod 100 -93 · =
' · r 3 = ' (21, x 98 + 53)
mod 100 = 2111 mod 100 = 11 '
' mod 100 = 284 · mod 100 = ·84 '
r4 ~ (21 x 11 -+ 53) \ I

r5 = (21 x 84 + 53)
mod 100 = 1817 ' mod 100 = ·11 ·..:· _··
(
r
mod 100 ' = 410 mod 100 = ·· 10 1~ ' "'
.. 6 = (21 x 17 + 53)
r1 = (21 x 10 + 53)
mod 100 = 263 mod 100 = 63 · ·
•. ' r8 = (21 x 63 + 53) mod 100 = 1376 mod 100 =;: 76·: · · ·
•. : r =.(21 x76+5 3) mod 100 = 1649 mod 100· ·= ·· 49 ···
9
·,
10
= (2Jx4 9+53) modlOO = 1082 mod JOO = · 82 · :I .
The required sequence of random numbers is 52, 45, 98, 11, 84, 17, I0, 6~~ -'~• 49, 82.'
(b) 'n+ 1 = (l3rn + 15) mod m '• · · ·! · •
Since the random numbers required have to be between Oand 31, the value of n, will
as 32.• I • , , ., .I • t ~ ' ~ . . I < •

,l ..
flandom Numbers 71

, ~ . ·. . :. r, = ( 13 x 11 + 15) . m
ri = (13 x 30 + 15) od 32 1 = . 158 ·. mod 32 . =· 30 ' ..
r3 = (13 x 21 + 15 mod 32 = 405 mod 32 . = 21
=.
.!4: (13 x 0 + 15 ) ~od 32 = 2~8 ~' mod 32 · = 00 . · . : . '
32-- -~--- t 5__ mo.d 32 ..•=. '• 15 · • :• '.
r s•= 3x15
(1
..
• . .. - - -i ) ·•--mod -
+ 5) mod 32 - 210 - --d· ... - - ·---· ·--- ·-·•· ··-
,,' IJI,'

.A-·
· r6 ·= (13 x 18 +
) -- -·- ::~. _ ~o 32 = 18 -,
,· r, = (13 x 25 + 15 15) mod 32 .. · 71.249 mod 32- ·; -.. 25 .... ~: ::. ---
mod 32 .- = 340 mo d 32 = 20 ... _;
, rs ·.= (13 x 20 + 15) . ..
. mod 32 . = 275 d3
. ·.r, = (13 x 19 + 15 · · mo 2 = 19 , , .
Therequt redseque nceofl0 num bers ts _) 11mod32 .=.· 262 mod32 = 06 .r . .
,
30 21 J

Example 4. 7. Generate . a sequ ence of five rand ' ' , 00, , b15, 18, 25, 20 ' 19' 06 . I. '

(a) r, + = ar mod m, taking _ nu~ ers such that . r °~


b) 1_ ( I · a - 16, m = 23 and r0 = 15
( r,.+ 1 - r 1 + b) mod m, takin g b -- l 1, m =· 17 ·and ·r - · I .
o u aon: · -, .. o-
S I t ,. .: ~ ·'. \

(a) !;+' =ar1 mod m = 16r.I mod 23



..... -
. . · r0 =, 15
. IVen
· G . r -··'...:_ ' ·-·'. !· , ~-··:·· • . • , . , 'J-. , ,, ... ·- .:,--. =---~ ----~ -- ·---.
.. ..,. ,I,.-• • • ~_. <w, ,,,. • " •• •

, - 16x 15 mod23 ,::;;:: 240 \.:•mod23 -~ ·· 10 ·-c ~ :· , l

=. 1~ x 10 mod 23 = 160 mod 23 = 22 .. ·


. / 2.
. , . rt = 16 X 22 mod'ij(' ;:; i ~'352 ~·'mod 23 \ ~'•, 1·.,·: ."".: ', .. '
mod 23 = 112 · ·mod 23 ~ · 20 · · ·: '·
l .., i ,I ) ) !i J t I ' I • ' -• '

r4 = 16 x 1
r5 = 16 x 20 mod 23 = 320 mod 23 = 21
r = 16 x 21 mod 23 = 336 , m~d 2/ ·~ ·· 14 " ·, + ·,
mod .23 . = .224 ~~d 23·· ~' 17 \ ·i ' · ;
6
r = 16 x 14
1
rg = 16 ·x 17 ~od J ~ 'iri mod 23· 19·,:· ~ ( ;
l •' '
2'f '~ I. 1 I I ---
r.: '
, : J •
I, ~ ..

r = 16 ,x l9 mod 23 = 304 modi 2f -~ · s ·


= 16 x 5 . mo~ 23 . = 80f , mod 23 ·= 11. ·. ~ · ·
' ' I • • ' \ , 1 / • , , ,• / ' '
9
,

= 16 ~ 11 mod 23 = 176 mod 23 ~ · i's · ·


.., , I • ., I ; •
• I ' al
10
,
11
The required sequence of r~dom n~~fS '\s 15, 10', 22, (q, 20, 21, i4, 11: 19,' 05.
(b) r + =(r,+b)m odm=(r, +ll)mod 17 ° · · ·•:' .'.:• ·
1 1 r = I
Given ... ' · · · · · · ., '
0
r = ( I + 11) mod I 7 :d · 12
1 , I '
, '. I '\ '
, , ,·
, • .. • :
,
t •

r,:'(12+ 11) 'ritodl7= 06 . , .. ".·:.. , ,, .. , :·•


, .,. , . , _,i·, = (6 + II) .mod _17 =.. 00 ,, . · ,. _... , . , . , ; _ , .. ,- ·"" . :
.... ~,: r = _(O+ll) _modl7. =_. 11 ; . ,~·'' -!-.•·, _, : . ' __ ,:

. . .. :, ,,,;, 4
.(tl .+ll)mo d17:' .05 •"·, •.,·. •...., . _,..:, , ·· . • ,:c·r.. .:
r,
= (S + 11) mod 17 :::: ;_: )6 ; .L:,. , ,·, ... · '! . • r: .- . ·:: . ·: .. .
.. . r = (I 6 + JI) mod 17 = Io , . ' _. , : · . : , . , ,. ·, c1
, 1 = (JO+ 11) mod 17 = 04 . · ·:. 1 . , • .. • ~,

r 1 = (4 + 11) mod 17 = 15 . . .• , .. 1. , ,o )
· ,
9
= (15 + 11) mod 17 = 09 ·, T I
Tho required sequence 10
of random numbers is 01, 12, 06, OO.. lll 05, 1,6,.J.lj...,.,,418!)
t, . -J :..
72 Sy~tem Simulation

Example 4.8. Use the mid of square method to generate 10 four-digit numbers, taking the seed
as 9876. . .
Solution: After squaring the given four-digit number, we wiJI chop off the last two digits and
then take the next four as t~e. mid of the square. This will give the next four-digit random number.
r; r; 2 - ; I ! . . , . .. ,.. '.
r, ~ I
9876 -97,5353, 76
I ...
... ' -5353
l I
5353 28,6546,09 I • .- 6546
6546 .l ·.: 42,8501, 16 .- ~ ' i 8501
8501 •- ·,-, ... 72,2670,0 t · : ( 2670
2670 •'· i ,- '· 7,1289,00 ,L .. , , .. 1289 ;

·,. ,. .
1289
.I
., •. ,t
1,6615,21 . '· d ·' . - . 6615 · · - · ... . ' )
'

6615 ' ,,,. ' -<


43,7582,25 7582.. ' ·-

7582
I
- 57 ,4867,24 . ,
.. ,·
' ) I I
t ' l '
4867 '
4867 23,6876,89 6876
6876 ~ , '. .· ' . l , .. j

~ . . ~ .
Thus, 9876, 5353, 6546, 8501, 2670, 1289, 6615, 7582, 4867, 6876,is the required sequence
~
I • --- • • •
I ' i -
of random numbers.
' • _ • -- - •
y

,
'

.,
,•

.. . . .. · .
Exam pie 4.9. E~~loy. th~'. a~ithmeti~ 'congr~ential gen~rai~~.: t~_~ge~erate a sequence of 1o'
-
random numbers given r, =987 r 2 = 535 _and modulo m =
. ::: .
' . . \ '

1000 · :
•~ \ •, - j ; i • ?
Solution:
f ~. I -•

• ;: , · ·: ,fr · .. ~ ~~ '< ::;: ... :-


ri + 2 = (r; "f:'l;+ 1) modulo m ·
r3 = (r1 + r 2) modulo 1000 ' ~
1

= (987 + 535) mod'! 1000


• r "'
I
= 1522 ::mod 1000 = 522 ·: - '

1
f t ' .,. ." • • f • • I' • t
r4 = (535 + 522) mod 1000 = 1057 mod 1000 = . _057,
r5 = (512 + 057) mod' iocio' = J579 -~od 1000 =·· 579
r6 = (057 + 57~)- ~od· iO~~ = _636 . mo~ 10_ 90 · = .636 '. __
1
r7 = (579 + 636) ,mod 1qoo _= 1215 mod 1000 = 215
+
rs ~ (636 215) 'mod 1000 ·=· .s's1 . mod I()()0 , ~'-- 851
1

r9 = (215 + 851) mod 1000 = 1066 mod 1000 =· 066


·r 10 = (851 + 66) mod 1000 = 917 mod 1000 = 917 . ' -~
987,535,5 22,057,57 9,636,215 , 851, 066~ 917 is the 'requir~d sequence of random numbers.
f • \ • \ ~ I I , :- • I

Example 4.10. A sequence of I 0,000 random numbers, each of four digits has been generated.
This sequence is to be tested for independence using.Poker Test. The analysis of the numbers reveals
that in 5120 numbers all four digits are differe'nt, in 4230, the're is one pair in each number, in S60,
there are two pairs, while in 75, there are three ·digits of a kind and in IS cases all the four digits are
same. ,Determine, if the random numbers are independence at a= 0.0S. .·
In this example, each random number is of foui digits. The following combination are possible:
(a) Four different digits · 1 · ··: • : 1 , ' • '. _; c · ·
(b) One pair in the digits , , ., , 1 ~ .-:· -~

(c) Two pairs \ 1


1 ~ : 1 ,· , : ; • • • r"·
(d) ,Three digits of one kind ~- ' , L' , . ' 1 • ~:.. 1 ,
(e) All four digits of one kind.
flandom Numbers
73
The probability of occurrence of
. . . -~. . _ com b·.mat1on
· •
(a), that 1s •
four different •• •
d1g1ts 1s,
. p (a)= ,9 X .8 X .7 = 0.504 -· . .
The probability having one pair and the other two different digits is,

.
. p (b) =
(4)2 X .I X
'
.9 X .8 = 0.432
_The probability of having two pairs of like digits is:

. .. --· · ·
I '

· ·
._ •

... ::· ... f(c)=


(4) x.1 \x.1'.x.9=0.054
2
The·probab!lity of haying ·t~~ee digits of a ~~nd -i~, : .1. .
. ~ •' ' ~ : • } • . • ,· • t • • ! • ~
. . . ·,. . p (d) 7,] X .1 X .9 = 0.009
t' ,·
The probability of having all four digits of one kind is · · · ' · ···
p (e) = .1 X .1 X .1 = 0.001,
. The test is summarized below in Table 4.3 :· •.· • :, :'. · ,_. ; . 1 •

. Table 4.3 . ,
Combination Observed.,, . ,,.::•·· ·, ,.,, . -, •! i, (0 -£.)2
Distribution · Distribution Expected ,· i ~,
,. '
;, , , • , E.
i 0.I •• .' .I •• ! . ,.. I
I
'I I '

Four different digits 5120 '•. I ,\\' • ... t :• 5040 ,: ( C.. ~ ' •; •, : • 1.2698
Pairs 4230 1
'•; ~ 4320 f :: : ;-:- : · ' 1.8750
Two pairs ,· · ,-. · : i", ,. 560 l! ,,; , , · · '·· r, ,540 · ;, · ··' · ·' ) '.''.--< ·• 0.7407
Three of a kind ; .;: 75 ,G ,' ,:'.! .,j,:j 90 · 2,5000 o1 : •

Four of a kind . 15 , . , ·! ,
• '
. :. _,
\.. ¥
, I0
I 2.5000
10000 10000 8.8856
Since, there are five combinations, number of degrees of freedom is four. The critical value
)Jos. 4 = 9.49, which is more than the X2 obtained above. Hence, the hypothesis that the random
numbers are independent cannot be rejected on the basis of Poker Test. :. 1 .. r, .. . _,
Example 4.11. A sequence of ioQO three-digit random numbers has been gene~te~ and their
analysis indicates that 680 have three different digits, 289 contain exactly oi:ie pair of like digits and
31 contain three like digits. Using Poker Test, these numbers are to be tested for independ_ence at
<X=0.05 . . . , ·' , . . -
, !
In case of three-digit number, the possible combinations are ' · ' . ·
(a) All three of different kind
(b) One pair 1
I ~ i ., • I
1' . '
.(c) All three of same kind.
i ·I'
The probabilities of occurrence of these ~hree ~ombinations are, J -
1
' • • , ' ) ' ' l • (! ,._ '
. p (a)= .9 X .8 = 0.72 .
• ' . '1 - } •,

p.(b) ·=·(~} x .1· ~-~9 ~ 0·.27


. ~ 1/, : • I 1
· · p (c) = .t'x;:1=·0.01 /'
I. •

The c~lcul~tions of x2 are given in Table 4.4.. ,. ..'


9
.. · ,Table 4.4 '· ·
Combination Observed
Distribution , Distribution ' Expected ~
i o, E,

Three different digits 680 2:2222 720 ·,


One Pair
289 ..
1.3370
•, • . I
.270 1
'. '

Three of a kind .. 31 1 JO 44
• ·•· ' 1
.1000
JO?O . . IOOO 47.6592
is 2, orie less than the number of c·omb'mat10 .
The number of degrees of freedom i~ this. f case
. .d .. d
2 66 h h h . ,of the numbers is rejected. f
I '

Smee x o.os. 2 = 5.99 < 47. , t e ypot e~1s o ,~n. epen ~ ence

f 1 : '
. • - ,. •• . I \, I" • ' •• 1 , • , l 1 • ., i • ,( ; 1• , • '
1

4.15 Exercises · 1 ·.• ,. • 1 • J . . , , •, ' • •

I] w'th t WO-d1.
I. Describe a procedure to physically generate random ·numbers on .the interval (0 , I
accuracy.
~ ! ' • ., "I ) ,'

2. . Why do the random numbers generated by .:'omput er are called pseudo random numbers. Demo
. Gen
. the Mid~square random number g_eneration method, taking the following numbers as"seeds
· , . 1 , • •.- ....
40randomnumbersineachcase. i-· .,·,·, : ·· ·--.

(a)(i)2 ~6_1__ _(~i) I}?!.·.


_:\ (!.ij)..J ~7? . . (iv)3452 ,')
1

.... . ,~.- ....


·
.... ... ·- ... -··- "" """

of random numbers. ?.
. ence
What i~ wrong with each sequ_ . '

(b) (i) ~789 (ii) 7583 : , (iii) 3789 n, ;


numbers. :
3. Use the mixed congruential method to generate the following sequences of random
(a) A sequence of JO two-digit random numbers such' that
/. · i,j J; 1\•
· rn+ = (21r + 53) modulo 100. · , ' ; ; i. -~_-, . \ i •
..... ... . .... 1~ . . ,.~.n - · .•~ ..... , · - · - - - -.. - --•-•--.
- ... .......... ........... "•-· ....• . ...............
., I ..
Take r0 = 46. . .:.:: · ~--'-,.~- _ --~.. .. ... :,;,. i ' ·
(b) A sequence of JO random numbers between O and 40, such that :. , ·
· ·. ' · ' .... rn+I =:=(9rn+ 15)modulom. ·
..
Take r = 12. , , : , , · .' , ·. · ,··. '-
0

·, 4. Repeat problem 3;·when the mixed congruential method is reduced to · ··


(~~ multiplica!i~e co~~~ential me~hod . ' : · _. • i • , ,
1

(b) ·additive cong~e~tial method


Generate a sequence of IO random numb_ers empl_oying the Arithmetic cong~en~ial
gener~to~! w
S.
~ , '.
r1 = 89 and , 2 =38 modulus m =23. , 1 : ··, ,. ,
git random num
6. Use the multiplicative congruential method to generate a sequence of four three-di
Let r0 = 117, a= 3, m = JOOO. (PTU, B. Tee~ (P,rod.) M~f 2 , .,, ' .( •. i_ \. J •
• ~. ' •

7. The following sequence of random numbers have been. . generate' d


, .. ~ [ ~ ' .•

0.37, 0.55, 0.71, 0.97, 0.65, 0.29, 0.84, 0.78, 0.23 I (,. '. I

y distri
Use the Kolmogorov-Smimov Test with a= 0.05 to detennine, if these numbers are unifonnl
over the interval Oto J. ; ,. i . , .. I

ity emplo
8•. Take JOO two-digit random numbers from the 1'11!1dom .num~r table and.test their unifonn
the Chi-Squared Test. Are the numbers unifo~ lr distributed_~t ~~) 9_5 ~ conti_d~nce
.l~v~I_. J~
··· . · · -- • · ·· .. · · · '· ' .
confidence level?
~,r,dO"' Nu_m ~rs
75
. _ fest the random. numbers take n .in Proble
9 rn 8 for sen I
rest. a autocorref. 8t'•on, by employing the Chi-Squared
. Of JOO random nurnbe . .
A sequence
JO, these numbers are uniform1ly d" st ~ •s give
n below. U
test whether
· 21 . 1 •. 8 J , ~ 92 . · • ~ 23~~b~te~.
, . · · se Chi-Squared Test with a= 0.0S to
. .... .96 ;' ·, ,. · ~- · ·,· ,. · •·~ .. • ,. ,
-
62 . 12 0 ' ·, . ., . ' 20 ·, · 68
82 8 92 ,,, · . · .- i 51' :.. ,, ,, 79 ·~ #.,
· .., 84
3 7 65 · ~ 83 _
48 ~ - . 74 - - BS -.

;~ ::
74 22
~i 85 19 ;! 28
S2
10 .... : - ·-· :; •

67 . SI 86 16 II
71 , 12 . 07 87 29 62
75 56 72 .•'! . 1 . -38
• ' • I
. . ' '. .. .: 34 · : ·• '·

18 . 82 41 .: ' 40 . 67 ·, 24 86
06
. . n '
33 •
. .
06
14 • .-· • 79 . •
. '
84 ' . • ' " ' ' 29 63 .. '
! ';'' • ,'.. , '
.
. 0 I . . . 20 . 06
' I :

. . .
f
25 I

' . ·: ' !!
• •

. 35 '. I i 8 I ; ' : . :I 07 ",. ' ' . '88. ~ ..· 96 65 ' . 57 . . 47


54 . • ,, /, . ,,. 74 · ·.· · 68
' 91 .. . ' ·' ', ·
1
70 13
· ' ,12. 26 , 57 . 30 , 22 ' • ,,' ,, _,. ,85 ~ /,, ~9 1
I, ·: 't'

rci~e ~· ' : ·" :·. :- · ·/ . , , .


_
• :90 .. ~ ~
- 3 . .. 13 _·; , 3 t" ··_ •

JI, Test the num bers ·given in Exe 10, ,or mdepend ·
05 ' , ~~c~, by employing the Chi-Squared Test. Take
a== 0. · ;·, ·, ·. • ~--:. ' -· :·
numbers ti · .... ·
Take 100 five-digit random . · · . rom the rand om b · · · er Test
J>ok to check
11 · • · · . . . , .. -..... u
_. ,_. · . _,n. • ,_;m er table and emp loy
the unifo"!11 1ty o~t heir d1 strib utio n .. - .
1 ' · ··,_ · 1 ' 1 ; • •: .• ~, ,;• ·: · ! 1 •> . •. , ; .
I : .- ,
. ./ ' ·' ) I:
h,., b •.·,. ·" '
1 l i
. ..
13,· Asequence of IOOO fo~ r-di git num bers
cies. Use Pok·e·'·!s · ~to.en.dete gener_~ted and ~ ~J!alysi$ indicates the .
following
. . cofl,lbinations and frequen . . ' · ' '· r ·''est rmin e wh th th ber~ are andependent.
,. , . ,. ·' · · • c ~,. , •. · .. ,1 . ··-1 ~ , ~r ___ 5se n~m
Use a=::= 0.05 . l. ;, i. ' 1; ••·~,~, • •., , ,. ' ; .. ,; , t • '
'./'~• I
'' ..,..,,'
' "!
' ; n! ~·. ·.I ' j 1 '. • ., ; 1:;,· • 1 : i' ·; '.i , i I , ti
',), .:

Combination
\ :./ ;_
· .. ., . .· 't. , ' \
·
.Phservedfrequency
,,··i , ,
1
,(, • ◄ •' ; . f .,. ' l 'l
··
' ·
I
·· ~ ~
,
,. 1 I
. .· ,.. ·· . · ·
• •

.1 • ..
Four different digits . ,, , - • '\
, •••• ,· ~ l'., ,, •
1
' ii
\ ;.. • r • l J
. ..
•t 567 • \ ~ f •) ~ ~, ''.\
I ' . . •I. 'I,(\
ll
.! • r"": l
'
I '
f '"'"
• : ,,.. • ! .. ; I " ~ ,' ' I ' r '
f

• •

'i ~ . ;~
One Pair .. \ t' . ', } · , • ." ,~ r-'J90·:_•,1
' '\' ! ''' / }•j
' •
.~· ~,p· · d '11• ;']-~ .
• • t • ; •~

...
. ! ir l• , g ·,
\., ' ' • \ ·' • I ._'
-' ,"

'· Two pairs i .

.Three digits of a kind


)
. .. .. Four digits of a k_ ind . \· !- -
.. • '
. ' ' I ·, l
' l000 f •·. . I : .•. 'i , / "! 1 .' . : " • : ·', , ,. •• ••
' 4

number~ using the 'multiplicative


' ,

erat e four -dig it rand om


14. Write a computer program that will gen .' ' I '
tial met hod .' AH ow the 'user' to inpu t valu es of ro: a, b and m:1 ,.,,:;, ',,! . .,/ .
congruen ' '! ,· t / ' 1 •1 ' ' ; l ,. :- · .,

using procedures you learned


ce of num bers for unif orm ity and· inde pendence


Ii Test the followin g seq uen i ' ' . •, • '. . ' .. • I J

in this chap ter: . ' . !; : . '.' . " ',. I ' '

866 .053, .214, .Ill , .554,· .. .611, : ;, .


302
~
883 748 969
: . 900: ,125, ,724, •J'. :405, '. •,160, '. ,736 I
:964: ."033: ..444: ..459
sim ulation? . : ·· ~. ' 1 · ,
a) What do you mean by system bers? Discuss the
called pseudo random. num . : . : . . .
..,, erated by com puter are . . .,
,,, Why the random num bers gen ·
numbers .., .. -. ' ' · ·· •· '' · ~ ·. ,~ · ·
consn,ence methQd of. generating random .-1 : i1:; . .: ~ .
'.

You might also like