IE306Lec6 - IE306 SYSTEMS SIMULATION Ali Rıza Kaylan...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: IE306 SYSTEMS SIMULATION Ali Rıza Kaylan kaylan@boun.edu.tr 1 LECTURE 6 LECTURE OUTLINE Random Numbers Random Number Generators Linear Congruential Generators, Multiple Recursive Generators Random Number Tests Uniformity Tests, Independence Tests, Gap Test, Poker Test 2 RANDOM NUMBERS Independent identically distributed uniformly distributed numbers between zero and one. Ui ~ IID Uniform(0,1) ;i=1,2,...,n u = {u1 , u2 ,..., un } These points are sometimes undesirably too evenly distributed in the ndimensional [0,1]n hypercube. 3 RANDOM NUMBERS PSEUDO random numbers: Even though they are obtained by a deterministic method, they behave statistically as random. Practically, all random number generators are deterministic automata with a finite state space, and so have a periodic behaviour. 4 RANDOM NUMBER GENERATORS DESIRABLE PROPERTIES Long period length Good statistical properties High speed: For certain simulation applications,billions of random numbers are required. Low memory usage: When many substreams must be maintained in parallel, effective memory utilization could be important. 5 RANDOM NUMBER GENERATORS DESIRABLE PROPERTIES Repeatability: The same sequence of random numbers is to be reproduced. Portability Ease of implementation Availability of jumping ahead and splitting facilities: The possibility of quickly jumping ahead to state sn+m given the current state sn. 6 MIDSQUARE METHOD Z(I) 2159 Z(I)*Z(I) 04 6612 81 X(I) 0.6612 I 1 2 3 4 5 6 7 8 9 10 Z(I) 2159 6612 7185 6242 9625 6406 368 1354 8333 4388 Z(I)*Z(I) 4661281 43718544 51624225 38962564 92640625 41036836 135424 1833316 69438889 19254544 X(I) 0.6612 0.7185 0.6242 0.9625 0.6406 0.3680 0.1354 0.8333 0.4388 0.2545 7 MIDSQUARE METHOD I 1 2 3 4 5 6 7 8 9 Z(I) 12 14 19 36 29 84 5 2 0 Z(I)*Z(I) 144 196 361 1296 841 7056 25 4 0 X(I) 0.14 0.19 0.36 0.29 0.84 0.50 0.20 0.00 0.00 8 LINEAR CONGRUENTIAL GENERATORS (LCG) Zi = (aZ i −1 + c )(mod m) where Z 0 = Seed, Starting Value a = Multiplier c = Increment m = Modulus EXAMPLE 1. a=7, c=5, m=16 Period = 4 a < m, c < m, Z0 < m, 0 ≤ Zi ≤ m − 1 for all i I 0 Z(I) 9 X(I) 1 2 3 4 5 4 1 12 9 4 0.250 0.063 0.750 0.563 0.250 9 LINEAR CONGRUENTIAL GENERATORS (LCG) EXAMPLE 2. a=9, c=5, m=16 Period = 16 I 0 Z(I) 7 X(I) I 10 Z(I) 1 X(I) 0.063 1 2 3 4 5 6 7 8 9 4 9 6 11 8 13 10 15 12 0.250 0.563 0.375 0.688 0.500 0.813 0.625 0.938 0.750 11 12 13 14 15 16 17 18 19 14 3 0 5 2 7 4 9 6 0.875 0.188 0.000 0.313 0.125 0.438 0.250 0.563 0.375 10 MULTIPLE RECURSIVE GENERATORS (MRG) Z n = (a1 Z n −1 +... + ak Z n − k ) mod m Xn = Z n / m the modulus m and order k are positive integers. a i ∈ {0,1,..., m − 1} For prime m and properly chosen coefficients ai , the MRG has a (maximal) period length ρ = mk − 1 This can be achieved with only two non-zero coefficients ai; Zn = (ar Zn −r + ak Zn −k )mod m 11 LAGGED FIBONACCI GENERATORS Zn = (Zn − r + Zn − k )mod m 12 COMPOSITE GENERATORS Two separate generators, X and I (shuffler) are used to generate the final sequence. X = X1 , X 2 ,..., Xk , Xk +1 ,... ~ Uniform(0,1) I ~ Discrete Uniform (1, k ) V = {X1 , X2 ,..., X k } The first k elements in the original random number sequence constitute the V sequence. The value for k is suggested as 128. The index I is generated from the discrete uniform distribution. V(I) is put as the first element in the final sequence. V(I) is replaced by X(k+1). The procedure is repeated to form the rest of the sequence. 13 COMPOSITE GENERATORS EXAMPLE: 0.102 0.927 0.041 0.764 0.155 0.658 0.769 0.015 0.786 0.252 0.739 0.036 0.47 0.604 0.726 0.426 0.707 0.583 0.214 0.713 0.491 0.217 0.083 0.575 0.653 0.971 0.936 0.679 0.923 0.402 0.733 8 1 0.102 0.102 0.102 0.604 0.604 0.291 5 1 2 6 4 5 4 2 0.291 0.291 0.291 0.291 0.707 3 0.927 0.927 0.927 0.927 0.927 4 0.041 0.041 0.041 0.041 0.041 5 0.764 0.764 0.739 0.739 0.739 6 0.155 0.155 0.155 0.155 0.155 7 0.658 0.658 0.658 0.658 0.658 8 0.769 0.015 0.015 0.015 0.015 I 8 5 1 2 6 V(I) 0.769 0.764 0.102 0.291 0.155 14 RANDOM NUMBER TESTS UNIFORMITY TEST H0 : H1: X is Uniform(0,1) X is not Uniform(0,1) Chi-Square Test 15 RANDOM NUMBER TESTS INDEPENDENCE TESTS H0 : H1: X' s are independent X' s are not independent Runs Test A run is defined as the succession of similar events preceded and followed by a different event. Up Run = Sequence of numbers each succeeded by a larger number Down Run = Sequence of numbers each succeeded by a smaller number 16 RANDOM NUMBER TESTS INDEPENDENCE TESTS I 1 2 3 4 5 6 7 8 9 10 X(I) R(I) 0.46 0.47 1 0.58 1 0.09 0 0.78 1 0.07 0 0.59 1 0.58 0 0.68 1 0.35 0 I X(I) R(I) I X(I) R(I) I X(I) R(I) I X(I) R(I) I X(I) R(I) 11 0.24 0 21 0.46 0 31 0.21 0 41 0.56 1 51 0.78 1 12 0.17 0 22 0.66 1 32 0.45 1 42 0.08 0 52 0.07 0 13 0.23 1 23 0.8 1 33 0.89 1 43 0.59 1 53 0.77 1 14 0.74 1 24 0.57 0 34 0.3 0 44 0.19 0 54 0.41 0 15 0.89 1 25 0.31 0 35 0.51 1 45 0.19 1 55 0.35 0 16 0.13 0 26 0.66 1 36 0.33 0 46 0.86 1 56 0.13 0 17 0.79 1 27 0.79 1 37 0.32 0 47 0.41 0 57 0.65 1 18 0.85 1 28 0.38 0 38 0.06 0 48 0.31 0 58 0.74 1 19 0.65 0 29 0.1 0 39 0.25 1 49 0.98 1 59 1 1 20 0.48 0 30 0.59 1 40 0.31 1 50 0.76 0 60 0.69 0 17 RANDOM NUMBER TESTS INDEPENDENCE TESTS Let A denote the total number runs and L denote the Maximum Run Length 2 A ~ Normal( µ, σ ) µ= 2n − 1 3 16 n − 29 σ2 = 90 approximately for n>20 where Z= A− µ σ 36 − 39.7 3.22 Z = −1.1 Z= A = 36 L=3 Number of 1's = 29 Runs above and below median 18 RANDOM NUMBER TESTS Gap Test Let Y denote the number of observations until the specified digit is observed Y~Geometric(p=0.1) Poker Test Consider 3 digit numbers Possibilities: P(All three different)=0.9*0.8=0.72 P(All alike)=0.1*0.1=0.01 P(Exactly one pair)=1-0.72-0.01=0.27 19 ...
View Full Document

This note was uploaded on 07/30/2009 for the course INDUSTRIAL ie306 taught by Professor Alirizakaylan during the Spring '09 term at Boğaziçi University.

Ask a homework question - tutors are online